WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome
This error message...
WebDriverException: unknown error: cannot find Chrome binary
...implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.
As per the ChromeDriver - Requirements:
The server expects you to have Chrome installed in the default location for each system:
OS Expected Location of Chrome Linux /usr/bin/google-chrome1 Mac /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome Windows XP %HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe Windows Vista and newer C:\Users%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe
Selenium driven ChromeDriver can't find Chrome binary
This error message...
WebDriverException: Message: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 10.0.18362 x86_64)
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- You are using chromedriver=2.40
- Release Notes of chromedriver=2.40 clearly mentions the following :
Supports Chrome v66-68
- As you have uninstalled Chrome and reinstalled presumably you are using the latest chrome=85.0
- Release Notes of ChromeDriver v85.0 clearly mentions the following :
Supports Chrome version 85
So there is a clear mismatch between ChromeDriver v2.40 and the Chrome Browser v85.0
Solution
Ensure that:
- Selenium is upgraded to current released Version 3.141.59.
- ChromeDriver is updated to current ChromeDriver v85.0 level.
- Chrome is updated to current Chrome Version 85.0 level. (as per ChromeDriver v85.0 release notes)
- If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- Execute your
@Test
as non-root user.- Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.Selenium gives selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary on Mac
The issue is that chromedriver also needs to know where chrome is. In your case it is at a non-default path. So you need to specify the complete path to the
Google Chrome
binary.options = webdriver.ChromeOptions()
options.binary_location = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
chrome_driver_binary = "/usr/local/bin/chromedriver"
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)Above code is what you should use
Related Topics
Differencebetween a Function, an Unbound Method and a Bound Method
How to Escape Os.System() Calls
Double Iteration in List Comprehension
What Rules Does Pandas Use to Generate a View VS a Copy
Stacked Bar Chart with Centered Labels
Syntax Behind Sorted(Key=Lambda: ...)
How to Do Exponential and Logarithmic Curve Fitting in Python? I Found Only Polynomial Fitting
How to Convert String to Binary
Pandas: Multiple Conditions While Indexing Data Frame - Unexpected Behavior
Split Cell into Multiple Rows in Pandas Dataframe
Pandas Groupby: How to Get a Union of Strings
How to Turn a Python Datetime into a String, with Readable Format Date
The 'Is' Operator Behaves Unexpectedly with Non-Cached Integers
Hash Function in Python 3.3 Returns Different Results Between Sessions
What Is the Intended Use of the Optional "Else" Clause of the "Try" Statement in Python