Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium gives "unknown error: cannot find Chrome binary" when running chrome driver on Ubuntu

I am trying to run selenium [java] tests using chrome driver on Latest ubuntu.[16.04]

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 believe the print "Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 15306" is coming from chrome binary. But why selenium complaining that its not able to get the binary?

Everything works fine on Windows.

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(java.base@9-internal/Native Method)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(java.base@9-internal/NativeConstructorAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(java.base@9-internal/DelegatingConstructorAccessorImpl.java:45)
     [java]     at java.lang.reflect.Constructor.newInstance(java.base@9-internal/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)
like image 761
George Avatar asked Apr 07 '17 21:04

George


3 Answers

Pointing to binary location, helped to fix the issue.

Changed from :

capabilities: {
    'browserName': 'chrome'
}

To:

capabilities: {
    'browserName': 'chrome',
    "chromeOptions": {
      'binary': "C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe",
      args: [],
      extensions: [],
  }
like image 141
Vladyslav Didenko Avatar answered Nov 17 '22 04:11

Vladyslav Didenko


I found the problem. On my linux system, Google Chrome Browser was not installed.

I was under the impression that ChromeDriver binary has got a browser implementation in it. Now I realized that's wrong , ChromeDriver binary is a selenium wrapper that calls Google Chrome.

I must say that the exception message "selenium.WebDriverException: unknown error: cannot find Chrome binary" is confusing. If it was telling that "Chrome Browser is not installed" or something similar it would have been much easier.

Thanks George

like image 37
George Avatar answered Nov 17 '22 04:11

George


Check the version of chrome install on your machine, then download the same version from https://sites.google.com/a/chromium.org/chromedriver/

like image 1
kushal Avatar answered Nov 17 '22 03:11

kushal