Webdriverexception: Unknown Error: Cannot Find Chrome Binary Error with Selenium in Python for Older Versions of Google Chrome

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:



























OSExpected 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 newerC:\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() within tearDown(){} 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



Leave a reply



Submit