Selenium on MAC, Message: 'chromedriver' executable may have wrong permissions - python

I'm just trying to do something very basic on my Mac using selenium and I can't even open a webpage. I'm getting an error of :
Traceback (most recent call last):
File "/Users/godsinred/Desktop/InstagramLiker/GmailAccountGenerator.py", line 10, in <module>
driver = webdriver.Chrome()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Here is my code below:
from selenium import webdriver
import time
link = "https://accounts.google.com"
driver = webdriver.Chrome()
driver.get(link)
time.sleep(5)
driver.quit()

Most answers here and in other related posts suggest users to just move the file to /usr/bin and they work fine if you are just running chromedriver locally and normally.
However, if you are compiling Python scripts into executables using compilers such as cx_freeze, you may not be able to afford the luxury if your program always uses a relative link to chromedriver.
As the error message suggests, your compiled program does not have the permissions to manipulate chromedriver. To use a relative link to chromedriver on a Mac in your compiled Python program, you can programmatically change the permission of chromedriver in your Python script using:
import os
os.chmod('/path/to/chromedriver', 0755) # e.g. os.chmod('/Users/user/Documents/my_project/chromedriver', 0755)
You can test this by doing the following:
cd to your working directory
$ chmod 755 chromedriver to allow your program to manipulate it
P.S. 755 is the default numerical permission for files in usr/bin. 664 is the default numerical permission for files in other normal folders (probably your working directory). Thus, when chromedriver complains it does not have the correct permission, you need to grant it a numerical permission equivalent to or greater than 755.

The error says it all :
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
The error clearly mentions that the chromedriver which is getting detected have wrong permissions.
Solution
Download the latest chromedriver binary from ChromeDriver - WebDriver for Chrome and save it in your system.
Ensure that chromedriver binary have the required permissions.
While initiating the WebDriver and WebClient pass the argument executable_path along with the absolute path of the chromedriver binary as follows :
from selenium import webdriver
link = "https://accounts.google.com"
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
driver.get(link)
Reference
You can find a detailed relevant discussion in:
'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

If you are on windows give path including file name. For example,
'./chromedriver/chromedriver.exe'
My line of code looks like below.
service = webdriver.chrome.service.Service('./chromedriver/chromedriver.exe')

This worked! I followed these instructions to update PATH: https://www.kenst.com/2015/03/installing-chromedriver-on-mac-osx/
I dragged my chromedriver.exe from Finder into Terminal (/etc/paths), and then copied the address in Terminal and dropped it into my Python IDE where the PATH should be inserted.

Check out a this topics
1- If you are using Linux, access the folder containing the file
Chromedriver.exe set on 755
2- check correct path for Chromedriver.exe file in your code
3- If you are using Windows servers,check the Chromedriver.exe file is available for the current user (not only the admin does have access to Chromedriver.exe - see in c://users...)

What worked for me in Windows was adding the location of the driver to Windows local PATH var, restarting my python environment so that the path to the driver displayed after running this:
import os;path = os.getenv('PATH'); print(path);
and then I did not specify the path when loading the driver:
from selenium import webdriver
driver = webdriver.Chrome()
if I tried putting the path in the Chrome() call it caused the permissions error. Adding it to the local environment path is enough.

Related

Expected binary browser location - traceback in Python

I've just started building my first bot and I'm struggling with the first step: automating a browser.
Here's my code:
from selenium import webdriver
browser = webdriver.Firefox(executable_path="/Users/ker/Downloads/geckodriver")
browser.get("https://app.finxter.com/")
When I try running the code I get the following error:
selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
I've installed the geckodriver unix executable and specified the path, but for some reason it still won't work and I can't really understand the error message.
You may get this error message for two reasons:
Firefox isn't installed in your system.
Firefox isn't installed in the default location within your system.
Solution:
If Firefox isn't installed, install it on your system.
If firefox isn't installed at the default location, you need to pass the path of the firefox executable through an Option() instance:
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.binary_location = r"C:/location/firefox.exe"
driver = webdriver.Firefox(options=options, executable_path="/Users/ker/Downloads/geckodriver.exe")
driver.get('https://app.finxter.com/')
Please check if your driver is executable
you can change the permission with the command below.
chmod +x /Users/ker/Downloads/geckodriver

Running selenium via geckodriver on raspberry pi 4 gives permission error [duplicate]

I've looked around checked both documentations and have found no answer.
I've been trying to use InstaPy a instagram api for python. After failing with multiple errors and assuming InstaPy is just having some issues so i tried to raw code it using selinium. after inserting the example code and alter it to my liking i just made sure this one would work. I received a new error instead of the old one saying the permissions may not be right. I have tried reinstall and running as admin but nothing works. how do i fix this and/or what does this mean
Code:
import time
from selenium import webdriver
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()
Error:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, 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:\Webdrivers\RawBot.py", line 5, in <module>
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search path.
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 86, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
This error message...
WebDriverException: Message: 'Webdrivers' executable may have wrong permissions.
...implies that the ChromeDriver variant you are trying to use have wrong permissions.
You seem to have tried out:
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search system $PATH variable.
A few words:
If your underlying os is windows:
You have to download chromedriver_win32.zip from the ChromeDriver Download Location and unzip it for usage.
Additionally, if you are explicitly specifying the Chromedriver binary path you have to append the binary extension as well, effectively i.e. chromedriver.exe.
While mentioning the Chromedriver binary path you have to either use the single forward slash i.e. (/) along with the raw (r) switch or you have to use the escaped backslash i.e. (\\).
So your effective line of code will be :
driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
If your underlying os is linux:
You have to download chromedriver_linux64 from the ChromeDriver Download Location and untar it for usage.
Additionally, if you are explicitly specifying the Chromedriver binary path you don't have to provide any extension for the executable binary, effectively i.e. chromedriver.
While mentioning the Chromedriver binary path you have to use the single forward slash i.e. (/).
So your effective line of code will be :
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
If your underlying os is macos:
You have to download chromedriver_mac64 from the ChromeDriver Download Location and untar it for usage.
Additionally, if you are explicitly specifying the Chromedriver binary path you don't have to provide any extension for the executable binary, effectively i.e. chromedriver.
While mentioning the chromedriver binary path you have to use the single forward slash i.e. (/).
So your effective line of code will be :
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
This got solved when you enter the full file name which is "chromedriver.exe". Try this if you are on windows
You just have to add
/chromedriver.exe
at the end of the path like this:
driver = webdriver.Chrome('C:/Users/User/Downloads/chromedriver_win32/chromedriver.exe')
Note: If you copy the path from "File Explorer" you will get:
C:\Users\User\Downloads\chromedriver_win32
You will need to use double backslashes like this:
C:\\Users\\User\\Downloads\\chromedriver_win32
so you don't get a syntax error. Or you can just use forward slashes.
If you are on a linux os, changing file permissions could possibly fix the problem. But beware of what you do with permissions:
chmod 755 "/path to chromedriver file"
I downloaded the file via python itself, which unfortunately disabled execution permission and this was the quick fix for it.
in Linux you need to specify the FULL path including the file itself as well, not just up to the folder (in Linux by default the downloaded file for chrome driver comes in a folder, e.g. 'chromedriver_linux64', open the folder and check the exact file name as well, usually 'chromedriver'):
from selenium import webdriver
chrome_driver_path = "/home/mn/chromedriver_linux64/chromedriver"
driver = webdriver.Chrome(executable_path=chrome_driver_path)
driver.get("https://www.amazon.com")
if you are using chrome you must specify the full path of the chromedriver.
search for the directory in which your chromedriver executable file resides.
click shift+right click on the executable file.
select "copy as path" and paste it in your script.
don't forget to use a double backslash
so it should be:
driver = webdriver.Chrome('C:\\Utility\\BrowserDrivers\\chromedriver.exe')
If you use a Mac OS Big Sur, and Chromedriver 90+, you might have an error with the permissions of your Chromedriver.
If this is the case, it's not the file permissions that you change via "chmod," instead, it is apple-store protection that forbids the execution of the web driver.
If you like to allow this driver to be used within your Python environment or via command-line, enter:
`$ sudo xattr -r -d com.apple.quarantine /usr/local/bin/chromedriver`
had same issue in django.
However when I ran the same code locally (not activating my django app) it was fine and didn't have to explicitly define the path to the chrome driver.
Got around it by explicitly defining the path and the chromederiver.exe
similar to the answer above.
path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
in my case, since I want to eventually post my app I used dynamic paths
ie.
import os
BASE_oaAPP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_oaAPP_Utilities_DIR = os.path.join(BASE_oaAPP_DIR, 'mySubFolderInTheApp')
def utilsPathFileName(fileName):
return os.path.join(BASE_oaAPP_Utilities_DIR, fileName)
chrome_path = utilsPathFileName('chromedriver.exe')
driver = webdriver.Chrome(chrome_path)
WINDOWS : Giving complete file path solved problem.
Many tutorials and articles are recorded with previous versions, where you just give directory path containing web drivers. But now you also have to provide specific driver path you're using.
Instead of C:/WebDrivers give complete file path as C:/WebDrivers/chromedriver.exe
chmod 755 "/path to chromedriver file"
This has helped me
The same problem. My solution was in Linux os, Pycharm editor...
Make sure your webdriver file with other python files (such as selinum_driver.py)
Then just copy the path and paste it into your webdriver.Chrome('path')
Don't need to write webdriver.exe
driver = webdriver.Chrome('/home/raju/Documents/Python-selenium/chromedriver')
For WINDOWS 10: I ran into a similar situation with the same error message when running my test code in Visual Studio Code. What solved it for me was to close out of the VS Code app and re-open the app as an administrator via the right-click menu.
For me, none of the answers above worked. But moving the chromedriver.exe to a new path (desktop in my case) solved it.
path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
I got the same error when wrongly installed drives(when for mac was downloaded windows drivers) once I correct it worked fine
You need to add exe at the end of the path of driver and it works.
locate your installed driver.exe,
shift+right click,
copy as path,
paste it to your IDE
we can fix this issue for centos
#Install package chromedriver. Install it using yum
yum install chromedriver
#Import following package in python.
from selenium import webdriver
#Add following options before initializing the webdriver
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("--headless")
chromeOptions.add_argument("--remote-debugging-port=9222")
chromeOptions.add_argument('--no-sandbox')
driver = webdriver.Chrome('/usr/bin/chromedriver',chrome_options=chromeOptions)
If you run it on a Windows computer you can also add it to Windows PATH (environment variables) so you don't have to declare executable_path. You can just say: webdriver.Chrome(options=your_options)
I got his error for MacOs and on changing the path to the one given below, the issue was solved.
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
I kept having this SAME problem after:
my script did not recognize chromdriver.exe in my $PATH (yes, it's there)
gave run permissions to exe
passed 'path/to/chromedriver.exe' into Chrome()
This is what solved it:
Don't give .exe in the python path(just provide up to the chromedriver in the path)
example:
driver = webdriver.Chrome("/Library/Frameworks/Python.framework/.../webdriver/chrome/chromedriver")
Unfortunately I still cant' get my script to read the chromedriver.exe path from my $PATH variable. Would still appreciate if someone helped out, although it's beyond the scope of this question
Windows users and visual studio code: while mentioning the Chromedriver binary path you have to either use the single forward slash i.e. (/) along with the raw (r) switch or you have to use the escaped backslash i.e. (\).
as well use the exact path and add chromedriver.exe at the end of the path to point directly to the executable:
driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
or:
driver = webdriver.Chrome(r'C:\\Users\\wanja\\Downloads\\Compressed\\chromedriver_win32\\chromedriver.exe')
this error means that file chromedriver is not executable,
I fix this error with run command of (in linux):
sudo chmod +777 chromedriver
It means to make the file executable by everyone with access.

Chromedriver working in path but not with selenium (python)

I've been attempting to use the selenium webdriver with Google Chrome.
I have installed chromedriver, and set the path to it. This has been done correctly as when I run chromedriver in terminal I get the output
Starting ChromeDriver 2.38.552518
on port 9515
Only local connections are allowed
However, when I attempt to use the chromedriver on my python script:
from selenium import webdriver
driver = webdriver.Chrome()
I get this following error:
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
I've tried multiple methods of specifying the direct path and also putting the chromedriver file in the folder the python script is in. But nothing seems to be working and they all give the same error!
Please Help!
edit:
Path has been set in bash profile as such:
export PATH="~/drivers/:${PATH}"
Attempted Path specified in the python script as such:
driver = webdriver.Chrome("~/drivers/chromedriver")
Still with the same error of:
No such file or directory: '~/drivers/chromedriver': '~/drivers/chromedriver'
Java can't understand ~/drivers/chromedriver, Because only Linux Shell understand ~ is user home folder, But Java can't.
So your should use absolute path like /home/<userA>/drivers/chromedriver or relative path like ../drivers/chromedriver
You have to set the Path :
driver = webdriver.Chrome('C:/path/to/chromedriver.exe')
download selenium server-standalone-3.12.0.jar
and try this in a terminal:
export CLASSPATH=".:selenium-server-standalone-3.12.0.jar"

Selenium using python in mac getting error

File "helloselenium.py", line 2, in <module>
driver = webdriver.Firefox(executable_path=r'\usr\local\bin\geckodriver')
File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in __init__
self.service.start()
File "/Library/Python/2.7/site-packages/selenium/webdriver/common/service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: '\usr\local\bin\geckodriver' executable needs to be in PATH.
Selenium client tries to locate the geckodriver executable from the system PATH. You will need to add the directory containing the executable to the system path.
export PATH=$PATH:/path/to/directory/of/executable/
now you can change your code to this:
from selenium import webdriver
browser = webdriver.Firefox()
You need to add the driver to your PATH, read here How to put geckodriver into PATH?
Alternatively you can also hardcode the full path to wherever the geko driver is:
path = "put the full path here"
driver = webdriver.Firefox(path)
I had a similar issue recently as I am a new MAC convert. There’s a few options. First you can add the driver location to your path as explained above. To do this you can open a terminal and use the following to update it: sudo nano /etc/paths
This will allow you to add the path. Also it will display the other paths. Confirm the driver is in one of those.
If modifying your path isn’t something you are comfortable with, you can always use Homebrew to install geckodriver. This is well documented online. As an aside, when installing geckodriver via Homebrew, sometimes you need to install twice as it will not properly link the first time.
Good luck. Also this same process works for chromedriver should you decide to add Chrome coverage in the future.

'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

I've looked around checked both documentations and have found no answer.
I've been trying to use InstaPy a instagram api for python. After failing with multiple errors and assuming InstaPy is just having some issues so i tried to raw code it using selinium. after inserting the example code and alter it to my liking i just made sure this one would work. I received a new error instead of the old one saying the permissions may not be right. I have tried reinstall and running as admin but nothing works. how do i fix this and/or what does this mean
Code:
import time
from selenium import webdriver
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()
Error:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, 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:\Webdrivers\RawBot.py", line 5, in <module>
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search path.
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 86, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
This error message...
WebDriverException: Message: 'Webdrivers' executable may have wrong permissions.
...implies that the ChromeDriver variant you are trying to use have wrong permissions.
You seem to have tried out:
driver = webdriver.Chrome('C:\Webdrivers') # Optional argument, if not specified will search system $PATH variable.
A few words:
If your underlying os is windows:
You have to download chromedriver_win32.zip from the ChromeDriver Download Location and unzip it for usage.
Additionally, if you are explicitly specifying the Chromedriver binary path you have to append the binary extension as well, effectively i.e. chromedriver.exe.
While mentioning the Chromedriver binary path you have to either use the single forward slash i.e. (/) along with the raw (r) switch or you have to use the escaped backslash i.e. (\\).
So your effective line of code will be :
driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
If your underlying os is linux:
You have to download chromedriver_linux64 from the ChromeDriver Download Location and untar it for usage.
Additionally, if you are explicitly specifying the Chromedriver binary path you don't have to provide any extension for the executable binary, effectively i.e. chromedriver.
While mentioning the Chromedriver binary path you have to use the single forward slash i.e. (/).
So your effective line of code will be :
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
If your underlying os is macos:
You have to download chromedriver_mac64 from the ChromeDriver Download Location and untar it for usage.
Additionally, if you are explicitly specifying the Chromedriver binary path you don't have to provide any extension for the executable binary, effectively i.e. chromedriver.
While mentioning the chromedriver binary path you have to use the single forward slash i.e. (/).
So your effective line of code will be :
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
This got solved when you enter the full file name which is "chromedriver.exe". Try this if you are on windows
You just have to add
/chromedriver.exe
at the end of the path like this:
driver = webdriver.Chrome('C:/Users/User/Downloads/chromedriver_win32/chromedriver.exe')
Note: If you copy the path from "File Explorer" you will get:
C:\Users\User\Downloads\chromedriver_win32
You will need to use double backslashes like this:
C:\\Users\\User\\Downloads\\chromedriver_win32
so you don't get a syntax error. Or you can just use forward slashes.
If you are on a linux os, changing file permissions could possibly fix the problem. But beware of what you do with permissions:
chmod 755 "/path to chromedriver file"
I downloaded the file via python itself, which unfortunately disabled execution permission and this was the quick fix for it.
in Linux you need to specify the FULL path including the file itself as well, not just up to the folder (in Linux by default the downloaded file for chrome driver comes in a folder, e.g. 'chromedriver_linux64', open the folder and check the exact file name as well, usually 'chromedriver'):
from selenium import webdriver
chrome_driver_path = "/home/mn/chromedriver_linux64/chromedriver"
driver = webdriver.Chrome(executable_path=chrome_driver_path)
driver.get("https://www.amazon.com")
if you are using chrome you must specify the full path of the chromedriver.
search for the directory in which your chromedriver executable file resides.
click shift+right click on the executable file.
select "copy as path" and paste it in your script.
don't forget to use a double backslash
so it should be:
driver = webdriver.Chrome('C:\\Utility\\BrowserDrivers\\chromedriver.exe')
If you use a Mac OS Big Sur, and Chromedriver 90+, you might have an error with the permissions of your Chromedriver.
If this is the case, it's not the file permissions that you change via "chmod," instead, it is apple-store protection that forbids the execution of the web driver.
If you like to allow this driver to be used within your Python environment or via command-line, enter:
`$ sudo xattr -r -d com.apple.quarantine /usr/local/bin/chromedriver`
had same issue in django.
However when I ran the same code locally (not activating my django app) it was fine and didn't have to explicitly define the path to the chrome driver.
Got around it by explicitly defining the path and the chromederiver.exe
similar to the answer above.
path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
in my case, since I want to eventually post my app I used dynamic paths
ie.
import os
BASE_oaAPP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_oaAPP_Utilities_DIR = os.path.join(BASE_oaAPP_DIR, 'mySubFolderInTheApp')
def utilsPathFileName(fileName):
return os.path.join(BASE_oaAPP_Utilities_DIR, fileName)
chrome_path = utilsPathFileName('chromedriver.exe')
driver = webdriver.Chrome(chrome_path)
WINDOWS : Giving complete file path solved problem.
Many tutorials and articles are recorded with previous versions, where you just give directory path containing web drivers. But now you also have to provide specific driver path you're using.
Instead of C:/WebDrivers give complete file path as C:/WebDrivers/chromedriver.exe
chmod 755 "/path to chromedriver file"
This has helped me
The same problem. My solution was in Linux os, Pycharm editor...
Make sure your webdriver file with other python files (such as selinum_driver.py)
Then just copy the path and paste it into your webdriver.Chrome('path')
Don't need to write webdriver.exe
driver = webdriver.Chrome('/home/raju/Documents/Python-selenium/chromedriver')
For WINDOWS 10: I ran into a similar situation with the same error message when running my test code in Visual Studio Code. What solved it for me was to close out of the VS Code app and re-open the app as an administrator via the right-click menu.
For me, none of the answers above worked. But moving the chromedriver.exe to a new path (desktop in my case) solved it.
path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
I got the same error when wrongly installed drives(when for mac was downloaded windows drivers) once I correct it worked fine
You need to add exe at the end of the path of driver and it works.
locate your installed driver.exe,
shift+right click,
copy as path,
paste it to your IDE
we can fix this issue for centos
#Install package chromedriver. Install it using yum
yum install chromedriver
#Import following package in python.
from selenium import webdriver
#Add following options before initializing the webdriver
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("--headless")
chromeOptions.add_argument("--remote-debugging-port=9222")
chromeOptions.add_argument('--no-sandbox')
driver = webdriver.Chrome('/usr/bin/chromedriver',chrome_options=chromeOptions)
If you run it on a Windows computer you can also add it to Windows PATH (environment variables) so you don't have to declare executable_path. You can just say: webdriver.Chrome(options=your_options)
I got his error for MacOs and on changing the path to the one given below, the issue was solved.
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
I kept having this SAME problem after:
my script did not recognize chromdriver.exe in my $PATH (yes, it's there)
gave run permissions to exe
passed 'path/to/chromedriver.exe' into Chrome()
This is what solved it:
Don't give .exe in the python path(just provide up to the chromedriver in the path)
example:
driver = webdriver.Chrome("/Library/Frameworks/Python.framework/.../webdriver/chrome/chromedriver")
Unfortunately I still cant' get my script to read the chromedriver.exe path from my $PATH variable. Would still appreciate if someone helped out, although it's beyond the scope of this question
Windows users and visual studio code: while mentioning the Chromedriver binary path you have to either use the single forward slash i.e. (/) along with the raw (r) switch or you have to use the escaped backslash i.e. (\).
as well use the exact path and add chromedriver.exe at the end of the path to point directly to the executable:
driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
or:
driver = webdriver.Chrome(r'C:\\Users\\wanja\\Downloads\\Compressed\\chromedriver_win32\\chromedriver.exe')
this error means that file chromedriver is not executable,
I fix this error with run command of (in linux):
sudo chmod +777 chromedriver
It means to make the file executable by everyone with access.

Categories