This question already has answers here:
'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
(22 answers)
Closed 4 years ago.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
Game_Pin = input('Enter your PIN: ')
NickNAME = input('Enter your nickname: ')
def Enter_Press():
browser.find_element_by_name("Enter").click()
def Kahoot_Spammer(Game_Pin, NickNAME):
chromedriver = webdriver.Chrome(r'C:\WebDriver\bin\chromedriver_win32')
browser = webdriver.Chrome(chromedriver)
browser.get('https://kahoot.it/')
game_pin = browser.find_element_by_id("Game PIN")
Name = browser.find_element_by_id("Nickname")
game_pin.send_keys(Game_Pin)
Enter_Press()
Name.send_keys(NickNAME)
Enter_Press()
Kahoot_Spammer(Game_Pin, NickNAME)
Wondering what I have done wrong in the code above. The file I have put into the path and have ran the
icacls "pathtochromedriver" /grant Users:F
command through the command prompt but it still didn't fix the problem. I have been stuck on this problem for quite some while now.
Traceback (most recent call last):
File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\KahootSpammer.py", line 28, in <module>
Kahoot_Spammer(Game_Pin, NickNAME)
File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\KahootSpammer.py", line 13, in Kahoot_Spammer
chromedriver = webdriver.Chrome(r'C:\WebDriver\bin\chromedriver_win32')
File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
self.service.start()
File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 88, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver_win32' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Any ideas on how to fix this? Every time I ask this question I usually end up with a answer that will fix one thing but then another problem arises.
Try using webdriver.Chrome(executable_path=r"C:\WebDriver\bin\chromedriver_win32")
If that doesn't solves the problem than I think there might be an issue with the version of chrome driver you are using download chromedriver from this path
Chromedriver Download Link
and paste it in the directory
and test it for this code it should run smooth without any error
from selenium import webdriver
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path=r"C:\WebDriver\bin\chromedriver.exe")
for j in range(2,8):
for i in range(2,8):
driver.get('https://www.olx.com.pk/lahore/apple/q-iphone-6s/?search%5Bfilter_float_price%3Afrom%5D=40000&search%5Bfilter_float_price%3Ato%5D=55000')
str1 = '//*[#id="offers_table"]/tbody/tr['
str2 = ']/td/table/tbody/tr[1]/td[2]/h3/a/span'
str3 = str1 + str(i) + str2
a = driver.find_element_by_xpath(str3).text
print a
Comment below if you face any issue
for one thing:
chromedriver = webdriver.Chrome(r'C:\WebDriver\bin\chromedriver_win32')
browser = webdriver.Chrome(chromedriver)
^^ Here you create a webdriver.Chrome instance named chromedriver. Then on the next line, you attempt to create another webdriver.Chrome instance... but this time passing the existing instance to it? Not sure why you are attempting to create multiple instances of it at all, but that code is definitely not going to work. Just create a single instance of webdriver.Chrome and use it:
browser = webdriver.Chrome(r'C:\WebDriver\bin\chromedriver_win32')
Related
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
PATH ="/Users/kaikeichan/Desktop/python_webpage/chromedriver"
driver = webdriver.Chrome(PATH)
driver.get("https://tsj.tw/")
blow = driver.find_element(By.ID,'click')
blow_count = driver.find_element(By.XPATH,'//*[#id="app"]/div[2]/div[4]/div[2]/h4[2]')
items = []
items.append(driver.find_element(By.XPATH,'//*[#id="app"]/div[2]/div[4]/div[4]/table/tbody/tr[4]/td[5]/button[1]'))
items.append(driver.find_element(By.XPATH,'//*[#id="app"]/div[2]/div[4]/div[4]/table/tbody/tr[3]/td[5]/button[1]'))
items.append(driver.find_element(By.XPATH,'//*[#id="app"]/div[2]/div[4]/div[4]/table/tbody/tr[2]/td[5]/button[1]'))
prices = []
prices.append(driver.find_element(By.XPATH,'//*[#id="app"]/div[2]/div[4]/div[4]/table/tbody/tr[4]/td[4]'))
prices.append(driver.find_element(By.XPATH,'//*[#id="app"]/div[2]/div[4]/div[4]/table/tbody/tr[3]/td[4]'))
prices.append(driver.find_element(By.XPATH,'//*[#id="app"]/div[2]/div[4]/div[4]/table/tbody/tr[2]/td[4]'))
actions = ActionChains(driver)
actions.click(blow)
for i in range(100):
actions.perform()
count = int(blow_count.text.replace("您目前擁有", "").replace("技術點", ""))
for j in range(3):
price = int(prices[j].text.replace("技術點", ""))
if count >= price:
upgrade_actions = ActionChains(driver)
upgrade_actions.move_to_element(items[j])
upgrade_actions.click()
upgrade_actions.perform()
break
raceback (most recent call last):
File "/Users/kaikeichan/Desktop/python_webpage/actionchain.py", line 7, in
driver = webdriver.Chrome(PATH)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in init
super(WebDriver, self).init(DesiredCapabilities.CHROME['browserName'], "goog",
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in init
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service /Users/kaikeichan/Desktop/python_webpage/chromedriver unexpectedly exited. Status code was: -9
From what I see you have an error in line 7 as it's pointed out in the traceback.
In the line of code you define your path you're trying to use an absolute path.
PATH ="/Users/kaikeichan/Desktop/python_webpage/chromedriver"
The problem in here may be that you are not writing the right path to the chromedriver file. Your path should have a C: before user (that is if you have your project stored in your computer and not an external hard drive or something similar) like this:
PATH ="C:/Users/kaikeichan/Desktop/python_webpage/chromedriver"
Another thing you could try is adding a ".exe" in the end of chromdriver as it is a .exe file and you should specify that.
PATH ="C:/Users/kaikeichan/Desktop/python_webpage/chromedriver.exe"
I really hope this helps and I would suggest you try to use a relative path because it could be simpler to you. If your ".py" python file is in the same folder your chromdriver file is allocated then you could just define the path as "chromedriver.exe" and that would be an effective use of a relative path.
I am using selenium with python and have downloaded the chromedriver for my windows computer from this site. After downloading the zip file, I unpacked the zip file to my downloads folder. Then I add the path to the the Environment Variable "Path".
I want to get information from the site, but when I run code, I get this error and comletely don't understand what is it about.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
browser = webdriver.Chrome(ChromeDriverManager().install())
url = 'any_url'
browser.get(url)
if browser.find_element_by_id("yearlist_1").get_attribute("type") == "checkbox":
print("Element is a checkbox")
else:
print("Element is not a checkbox")
The error:
*'reg' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
File "C:/Users/miair/Python/script_gks/code_for_ticks.py", line 4, in <module>
browser = webdriver.Chrome(ChromeDriverManager().install())
File "C:\Program Files\Python37\lib\site-packages\webdriver_manager\chrome.py", line 28, in install
driver_path = self.download_driver(self.driver)
File "C:\Program Files\Python37\lib\site-packages\webdriver_manager\manager.py", line 36, in download_driver
driver_version, is_latest = self.__get_version_to_download(driver)
File "C:\Program Files\Python37\lib\site-packages\webdriver_manager\manager.py", line 27, in __get_version_to_download
return self.__get_latest_driver_version(driver), True
File "C:\Program Files\Python37\lib\site-packages\webdriver_manager\manager.py", line 21, in __get_latest_driver_version
return driver.get_latest_release_version()
File "C:\Program Files\Python37\lib\site-packages\webdriver_manager\driver.py", line 58, in get_latest_release_version
self._latest_release_url + '_' + chrome_version(self.chrome_type))
File "C:\Program Files\Python37\lib\site-packages\webdriver_manager\utils.py", line 114, in chrome_version
.format(cmd)
ValueError: Could not get version for Chrome with this command: reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version*
Sorry, I am very new to Python, but if somebody could help, I'll be very pleased and thankful.
I solved problem. I don't understand why I've hadn't think of this solution before - all you need to do is to write the path of your chromedriver (only if you have a correct version)
browser = webdriver.Chrome('path')
important to know for people searching for the same error and ending here. chrome needs to have started at least once to generate the reg key in windows.
I suspect that you are using a selenium web-driver that is not matching your chrome driver version.
you can update your chrome using the following link:
chrome://settings/help
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
browser = webdriver.Firefox(executable_path=r'/usr/bin/firefox')
browser.get("http://google.com/")
Ubuntu 16 LTS user here.How to fix this empty window issue after I enter url and is no loaded page there.
Output:
> > Traceback (most recent call last): File "/home/pc/PycharmProjects/calculator/test.py", line 781, in <module>
> browser = webdriver.Firefox(executable_path=r'/usr/bin/firefox') File
> "/home/pc/PycharmProjects/calculator/venv/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py",
> line 164, in __init__
> self.service.start() File "/home/pc/PycharmProjects/calculator/venv/lib/python3.5/site-packages/selenium/webdriver/common/service.py",
> line 98, in start
> self.assert_process_still_running() File "/home/pc/PycharmProjects/calculator/venv/lib/python3.5/site-packages/selenium/webdriver/common/service.py",
> line 111, in assert_process_still_running
> % (self.path, return_code) selenium.common.exceptions.WebDriverException: Message: Service
> /usr/bin/firefox unexpectedly exited. Status code was: 0
You need to provide geckodriver path not firefox. Check your firefox browser version and you can download compatible geckodriver from Here
browser = webdriver.Firefox(executable_path="path of geckodriver")
Sample code
browser = webdriver.Firefox(executable_path="/Users/username/Location/geckodriver")
browser.get("https://google.com")
You can add the path to your webdriver in the PATH system variable
export PATH=$PATH:/path/to/driver/firefox-driver
Add it to /home//.profile file to make it permanent.
Then you dont need executable_path=''
Firstly, I'd just like to say my level of python programming is absolute beginner so please be patient!
I've installed Python 3.7.4, along with some packages such as numpy, xlwings and (most importantly) selenium.
I've downloaded the this onto my 64-bit windows 10 laptop and followed the advice of the Python forum to address issues particular to Windows but still, when I try to run a slightly modified version of this example code which basically opens a browser (the sample opens firefox, I'm using Chrome - they both have this same issue!), navigates to facebook and logs-in.
My code is:
from selenium import webdriver
import time
username = 'fb_email#email.com'
password = 'fb_password'
url = 'https://www.facebook.com/'
driver = webdriver.Chrome(executable_path=r"C:\\Python37\\Lib\\site-packages\\selenium\\webdriver\\chrome\\webdriver.py")
driver.get(url)
driver.find_element_by_id('email').send_keys(username)
driver.find_element_by_id('pass').send_keys(password)
time.sleep(2)
driver.find_element_by_id('loginbutton').click()
When I run this code I'm getting the following error message:
Traceback (most recent call last):
File
"C:/Python37/Codes/Test.py", line 9, in
driver = webdriver.Chrome(r"C:\Python37\Lib\site-packages\selenium\webdriver\chrome\webdriver.py")
File
"C:\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py",
line 73, in init
self.service.start() File "C:\Python37\lib\site-packages\selenium\webdriver\common\service.py",
line 76, in start
stdin=PIPE) File "C:\Python37\lib\subprocess.py", line 775, in init
restore_signals, start_new_session) File "C:\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo) OSError: [WinError 193] %1 is not a valid Win32 application
You'll notice one other change I've made from the original code is I've include the full file path (explicitly referencing Webdrive.py file) to deal with the "permissions" error.
Basically, I just want to get to the stage I can run this code and I can do I know I can run selenium on python in principal and deal with the nested looping within the python code at a later date so any help/suggestions would be greatly appreciated.
Root Cause:
You are not providing the correct path to the executable_path in line # 9. executable_path should point to the chromedriver.exe path not the p.py path.
How to fix:
Update the line#9 with the correct path to the chromedriver.exe.
# make sure you add `.exe` file name too at the end like `chromedriver.exe`.
driver = webdriver.Chrome(executable_path=r"pathToChromedriver")
I have code of this
#!/usr/bin/env python
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import time
driver = webdriver.Chrome()
And the error occurs at the last line : driver = webdriver.Chrome()
It says this :
Traceback (most recent call last):
File "/Users/Edison/Desktop/untitled folder/huamai_jacket1.py", line 9, in <module>
driver = webdriver.Chrome()
File "/Users/Edison/anaconda2/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 61, in __init__
log_path=service_log_path)
File "/Users/Edison/anaconda2/lib/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 42, in __init__
start_error_message="Please see https://sites.google.com/a/chromium.org/chromedriver/home")
File "/Users/Edison/anaconda2/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 42, in __init__
self.port = utils.free_port()
File "/Users/Edison/anaconda2/lib/python2.7/site-packages/selenium/webdriver/common/utils.py", line 36, in free_port
free_socket.bind(('0.0.0.0', 0))
File "/Users/Edison/anaconda2/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 49] Can't assign requested address
Exception AttributeError: "'Service' object has no attribute 'log_file'" in <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x1049a93d0>> ignored
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/Edison/Desktop/untitled folder/huamai_jacket1.py"]
[dir: /Users/Edison/Desktop/untitled folder]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
Happens this morning and the thing is right after this happens, sometimes when i access website even like google.com, the ERR_ADDRESS_INVALID page shows up often and i need to keep refreshing to get the page back to the regular site.
Is this because that the driver.Chrome() does not include the PATH of Chromedriver location? I used my script for a week before today though and everything worked perfectly.
Please help :(
So if you do not pass a path as a part of the "webdriver.Chrome('path/to/chromedriver')" is will search along the PATH environment variable to find it. So first thing I would do is verify where my chromedriver is. If it is not in $PATH then you can put it in usr/bin and try running again. Or you can pass the path to your chromedriver executable in the .Chrome().