Selenium ошибка cannot find chrome binary

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 SettingsApplication DataGoogleChromeApplicationchrome.exe
Windows Vista and newer C:Users%USERNAME%AppDataLocalGoogleChromeApplicationchrome.exe

1 For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.


Using a Chrome executable in a non-standard location

However you can also override the default Chrome binary location as follows:

To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:\Program Files\Chrome\chrome64_55.0.2883.75\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:pathtochromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()

Related Docs


Reference

You can find a detailed discussion in:

  • Is Chrome installation needed or only chromedriver when using Selenium?

You fire up your Selenium-based Chrome browser automation operation(s) one fine day and you are greeted with a godawful bit of an exception, at the bottom of which you read the following:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

Puzzled, “It was working optimally just yesterday!”, you think to yourself, wondering what the variable causing this could be. The infamously trusty Stack Overflow does not tell you much about this, except that you probably need to explicitly set the Google Chrome binary’s path as so:

...
chromeOptions = webdriver.ChromeOptions()
chromeOptions.binary_location = "C:Program
FilesGoogleChromeApplication" chromeDriver = "/chromedriver.exe"
driver = webdriver.Chrome(chromeDriver, options=chromeOptions)
...

But, “dude”—you ask yourself—”why should I explicitly set the Google Chrome binary’s path?” or maybe “Why was this not required just yesterday?”

Well, for the curious minds that made it here, may you have the strength of a thousand Suns, for we are a different people that consist of special gears in our heads that start “churning” once an inconsistency makes its way into our lives; and instead of just “fixing” the capsizing ship with a chunky roll of Flex tape (not sponsored) over the cracks and holes, we would like to know how it happened, what made it happen, and why it happened—as we abandon ship and auto-inflate our enormous life raft (using Selenium, of course, ’cause “automation”) and then sail off into the sunset as we code an Apache helicopter into existence (what ship? Pfft).

Now if there’s one thing you can be sure of, it’s that nothing is more powerful than a young boy’s wish. Except an Apache helicopter. An Apache helicopter has machine guns AND missiles. It is an unbelievably impressive complement of weaponry, an absolute death machine.” —Morgan-Freeman-sounding-but-not-Morgan-Freeman narrator — Ted (2012)

We have digressed far into the 3.5th dimension here; apologies, here’s the reason and possible fix!

Reason

NOTE: Just for the sake of clarity, this “Chrome binary” that Selenium is referring to is simply the OG big daddy main “Chrome.exe” file located in Google Chrome’s installation directory.

In previous versions of Google Chrome (v84 and below), Google Chrome’s default installation path—where “Chrome.exe” typically is—used to be:

C:UsersUSERNAMEAppDataLocalGoogle

But since the newer iteration(s) (v85 and above), the default installation path is:

C:Program FilesGoogle

Now, this is the problem. Where the older chromedriver.exe versions (v84 and below) intuitively expect the Chrome binary to be is in the former path, not the latter. If your Google Chrome browser naturally auto-updated from v84 to v85, this path remains unchanged (so chromedriver.exe has no issues navigating to it). However, if you explicitly installed or reinstalled Google Chrome on the latest version (v85 and above) recently, then the installation path changes to the newer one, and so, your older chromedriver.exe is not able to navigate to the Chrome binary; and this makes your code end with that particular “cannot find Chrome binary” exception. Ergo, this is why you are having to explicitly set the “binary_location” to the latter manually

NOTE: Since Google Chrome does not allow customizing the installation path while installing and just directly installs into Program Files by default, We have already tried a workaround and changed the default installation path itself from the registry (regedit); but to no avail, Google Chrome would then completely refuse to work once installed in the desired directory. It seems newer Google Chrome installations can only function if they are installed in the newer installation path.

Possible Fixes

Download the latest chromedriver.exe version that corresponds to your Google Chrome version (from here), and replace your existing chromedriver.exe with this new one.

Your problem should now be solved, since the newer chromedriver.exe is equipped with the knowledge that the new Google Chrome installation path is where it is supposed to look in order to find the Chrome binary.

But—for whatever reason—if you do not want to upgrade the chromedriver.exe version, you could just downgrade your Google Chrome version by obtaining an older version that corresponds to your chromedriver.exe version, uninstalling the newer version, and then installing the older version you had obtained.

NOTE: You will not find any official downloads for older Google Chrome versions since Google does not allow this for security reasons, but you may find some unofficial sources like this (personally tested and verified, safe). Also be informed that upon installing an older version of Google Chrome, auto-updates will no longer work anymore; so the only way for a potential future update would be via an uninstall and manual install of the latest Google Chrome version.

I found that the path of chrome.driver in nightwatch web was wrong (Maybe it is just a demo)
I use below code to start my test if you has installed the chromedrive with command npm install chromedriver --save-dev:
In Windows:

 "selenium": {
    "start_process": true,
    "server_path": "./bin/selenium-server-standalone-3.141.59.jar",
    "log_path": "",
    "port": 4444,
    "cli_args": {
      "webdriver.chrome.driver": "node_modules/chromedriver/lib/chromedriver/chromedriver.exe"
    }
  }

In MacOSX:

"selenium": {
    "start_process": true,
    "server_path": "./bin/selenium-server-standalone-3.141.59.jar",
    "log_path": "",
    "port": 4444,
    "cli_args": {
      "webdriver.chrome.driver": "node_modules/chromedriver/lib/chromedriver/chromedriver"
    }
  }

Labrador retriever puppy walking on green grass

Sometimes, we want to fix WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome.

In this article, we’ll look at how to fix WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome.

How to fix WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome?

To fix WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome, we set the path of the Chrome binary.

For instance, we write

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:\Program Files\Chrome\chrome64_55.0.2883.75\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:pathtochromedriver.exe')
driver.get('http://example.com/')
driver.quit()

to set create an Options object.

Then we set options.binary_location to the path of the Chrome binary.

And then we set the executable_path to the path of the Chrome driver.

Then we call get to open a page at the URL and call quit to exit.

Conclusion

To fix WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome, we set the path of the Chrome binary.

Web developer specializing in React, Vue, and front end development.

View Archive

Answer by Anika Caldwell

…implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.,However you can also override the default Chrome binary location as follows:,As per the ChromeDriver — Requirements:,1 For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.

This error message…

WebDriverException: unknown error: cannot find Chrome binary

To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code block :

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:\Program Files\Chrome\chrome64_55.0.2883.75\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:pathtochromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()

Answer by Zyair Tate

In previous versions of Google Chrome (v84 and below), Google Chrome’s default installation path—where “Chrome.exe” typically is—used to be:,
Fix: Selenium’s «cannot find Chrome binary» Error ,Enter your e-mail address to receive notifications of new posts via email [Not annoying],Your problem should now be solved, since the newer chromedriver.exe is equipped with the knowledge that the new Google Chrome installation path is where it is supposed to look in order to find the Chrome binary.

You fire up your Selenium-based Chrome browser automation operation(s) one fine day and you are greeted with a godawful bit of an exception, at the bottom of which you read the following:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

Puzzled, “It was working optimally just yesterday!”, you think to yourself, wondering what the variable causing this could be. The infamously trusty Stack Overflow does not tell you much about this, except that you probably need to explicitly set the Google Chrome binary’s path as so:

...chromeOptions = webdriver.ChromeOptions()chromeOptions.binary_location = "C:ProgramFilesGoogleChromeApplication" chromeDriver = "/chromedriver.exe"driver = webdriver.Chrome(chromeDriver, options=chromeOptions)...

In previous versions of Google Chrome (v84 and below), Google Chrome’s default installation path—where “Chrome.exe” typically is—used to be:

C:UsersUSERNAMEAppDataLocalGoogle

But since the newer iteration(s) (v85 and above), the default installation path is:

C:Program FilesGoogle

Answer by Ezra Mendoza

If I uninstall Chrome v85 and install Chrome v84, the program works just fine.,@DavidGurley Did you do anything more than a simple Windows installer uninstall of chrome 85 in order to reproduce this?,Issues without a reproduction script are likely to stall and eventually be closed.,Previously, my «GoogleSearch.exe» Python program would open Chrome at the Google search page.

 selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary. 

Answer by Maverick Rangel

To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code block :,…implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.,Is Chrome installation needed or only chromedriver when using Selenium?,Check https://sites.google.com/a/chromium.org/chromedriver/getting-started
You can specify the binary path in the constructor of the webdriver:

I am using the following code to attempt to set my Chrome binary location:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:\Program Files\Chrome\chrome64_55.0.2883.75\chrome.exe"
driver = webdriver.Chrome('chromedriver.exe', chrome_options = options)

However, when I attempt to launch the WebDriver Python returns the following error:

WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)

Answer by Cayden Mendoza

How can I set the binary in Katalon Studio itself so it can open the browser where I have it located instead of having to write it in the script?,Please find the answers below:
a1) I am working on windows 7 professional
a2) Yes the path is same “C:Program Files (x86)GoogleChromeApplication”,I tried putting C:Program Files (x86)GoogleChromeApplication into the PATH environement variable but it showed no effect.,q2. What is the exact path to the chrome binary on your PC? If you are working on Windows 10, it would be C:Program Files (x86)GoogleChromeApplicationchrome.exe . As as yours?

I read the article [Tutorials>A Sample Web Automation Test Project] at
https://www.katalon.com/resources-center/tutorials/sample-web-automation-test-project/ , and made a TestCase just as described.
I ran it with FireFox successfully.
I ran it with IE successfuly.
I got failure with Google Chrome. The FAILURE message goes as follows:

Test Cases/Basic FAILED because (of) Unable to open browser with url: '' (Root cause: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.33 seconds
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: ********, ip: '***.***.***.***', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: driver.version: CChromeDriver)

Answer by Egypt Tate

To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code block :,…implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.,However you can also override the default Chrome binary location as follows:,I am using the following code to attempt to set my Chrome binary location:

I am using the following code to attempt to set my Chrome binary location:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:\Program Files\Chrome\chrome64_55.0.2883.75\chrome.exe"
driver = webdriver.Chrome('chromedriver.exe', chrome_options = options)

However, when I attempt to launch the WebDriver Python returns the following error:

WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)

Answer by Ira Cruz

org.openqa.selenium.WebDriverException: unknown er…,

▼ 

January
(4)

Selenium Interview Questions and Answers
org.openqa.selenium.WebDriverException: unknown er…
Can we pass more than one parameter in sendKeys() …
Ways to perform headless browser Testing with chrome

,

▼ 

2018
(13)

▼ 

January
(4)

Selenium Interview Questions and Answers
org.openqa.selenium.WebDriverException: unknown er…
Can we pass more than one parameter in sendKeys() …
Ways to perform headless browser Testing with chrome

► 

February
(2)

► 

March
(1)

► 

April
(4)

► 

May
(2)

,

Unknown
said…
10 September 2018 at 19:17

same error still occurs after using chromeOptions for binary… Runs fine on local system in eclipse but having issue on jenkins where I integrated jenkins with Git and committing code from eclipse to git.

[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ Maven.Final ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite

Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 32967
Only local connections are allowed.
FAILED CONFIGURATION: @BeforeClass setUp
org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 54 milliseconds
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:01:39.354Z'
System info: host: 'XXXXXXXXXX', ip: 'XXXXXXXXXXX', os.name: 'Windows 10', os.arch: 'XXXXXX', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)


Let see how to resolve this problem, if we run our project through intellj or eclipse using TestNG or Maven our Script will work fine but when we try to run this using Jenkins the Jenkins could not access the binary from our system, since It is possible that chrome is installed on your AppData folder in C drive, so we need to be sure that jenkins is able to access our chrome binary file.


Now to access the binary file we need to add below snippet




ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\Users\Manish\AppData\Local\Google\Chrome\Application\chrome.exe");
 System.setProperty("webdriver.chrome.driver","C:\Users\manish\Downloads\chromedriver_win32\chromedriver.exe");
 driver = new ChromeDriver(chromeOptions);


i hope this resolve your problem let me know if this won't work for you guys.


[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ Maven.Final ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 32967
Only local connections are allowed.
FAILED CONFIGURATION: @BeforeClass setUp
org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 54 milliseconds
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:01:39.354Z'
System info: host: 'XXXXXXXXXX', ip: 'XXXXXXXXXXX', os.name: 'Windows 10', os.arch: 'XXXXXX', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
Let see how to resolve this problem, if we run our project through intellj or eclipse using TestNG or Maven our Script will work fine but when we try to run this using Jenkins the Jenkins could not access the binary from our system, since It is possible that chrome is installed on your AppData folder in C drive, so we need to be sure that jenkins is able to access our chrome binary file.
Now to access the binary file we need to add below snippet
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\Users\Manish\AppData\Local\Google\Chrome\Application\chrome.exe");
 System.setProperty("webdriver.chrome.driver","C:\Users\manish\Downloads\chromedriver_win32\chromedriver.exe");
 driver = new ChromeDriver(chromeOptions);


i hope this resolve your problem let me know if this won't work for you guys.

ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\Users\Manish\AppData\Local\Google\Chrome\Application\chrome.exe");
 System.setProperty("webdriver.chrome.driver","C:\Users\manish\Downloads\chromedriver_win32\chromedriver.exe");
 driver = new ChromeDriver(chromeOptions);
i hope this resolve your problem let me know if this won't work for you guys.

Answer by Mario Brewer

python — Selenium on the Mac“ selenium.common.exceptions . webdriverexception: Message: unknown error: Chrome binary not found »
,I am getting the following error/exception.
As an experiment, I replaced ChromeDriver binary with my native «helloworldApp»; I found that selenium is executing my binary.,I am trying to run selenium [java] tests using chrome driver on Latest ubuntu.[16.04],
selenium — Through the driver chrome options and desiredcapabilities?

Please advice.

     [java] Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 15306
     [java] Only local connections are allowed.
     [java] Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
     [java]   (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 4.8.0-46-generic x86_64) (WARNING: The server did not provide any stacktrace information)
     [java] Command duration or timeout: 328 milliseconds
     [java] Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
     [java] System info: host: 'geo-VirtualBox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.0-46-generic', java.version: '9-internal'
     [java] Driver info: org.openqa.selenium.chrome.ChromeDriver
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0([email protected]/Native Method)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance([email protected]/NativeConstructorAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance([email protected]/DelegatingConstructorAccessorImpl.java:45)
     [java]     at java.lang.reflect.Constructor.newInstance([email protected]/Constructor.java:453)
     [java]     at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
     [java]     at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
     [java]     at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
     [java]     at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
     [java]     at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
     [java]     at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
     [java]     at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
     [java]     at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)

Понравилась статья? Поделить с друзьями:
  • Selection does not contain a main type eclipse ошибка
  • Selected boot image did not authenticate ошибка
  • Select и group by ошибки
  • Select main output device a1 ошибка
  • Select from если пусто то ошибка