Selenium: WebDriverError: unknown error: cannot find Chrome binary

Created on 13 Oct 2017  路  6Comments  路  Source: SeleniumHQ/selenium

Meta -

OS: Windows 10
Selenium Version: 3.6.0
Browser: ChromeDriver
Browser Version: 2.33.506120

Expected Behavior -

chromedriver work well with selenium-webdriver

Actual Behavior -

throw an error:

WebDriverError: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64)
    at Object.checkLegacyResponse (c:\Source_Code\spider.wihu.com\newSpider\node_modules\selenium-webdriver\lib\error.js:546:15)
    at parseHttpResponse (c:\Source_Code\spider.wihu.com\newSpider\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (c:\Source_Code\spider.wihu.com\newSpider\node_modules\selenium-webdriver\lib\http.js:441:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.createSession()
    at Function.createSession (c:\Source_Code\spider.wihu.com\newSpider\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
    at Function.createSession (c:\Source_Code\spider.wihu.com\newSpider\node_modules\selenium-webdriver\chrome.js:761:15)
    at createDriver (c:\Source_Code\spider.wihu.com\newSpider\node_modules\selenium-webdriver\index.js:170:33)
    at Builder.build (c:\Source_Code\spider.wihu.com\newSpider\node_modules\selenium-webdriver\index.js:642:16)
    at spider (c:\Source_Code\spider.wihu.com\newSpider\index.js:26:10)
    at Object.<anonymous> (c:\Source_Code\spider.wihu.com\newSpider\index.js:118:1)
    at Module._compile (module.js:570:14)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)

Steps to reproduce -

require('chromedriver');
const webdriver = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
var chromePath = require('chromedriver').path;
let service = new chrome.ServiceBuilder(chromePath).build();
chrome.setDefaultService(service);

let driver = new webdriver.Builder()
    .withCapabilities(webdriver.Capabilities.chrome())
    .build();

driver.get('http://www.baidu.com')
C-nodejs R-awaiting answer

Most helpful comment

If your Chrome is not installed in the standard location, you may have to explicitly specify it in your protractor.conf.js:

  capabilities: {
    'browserName': 'chrome',
    "chromeOptions": {
      binary: "/Applications/your_path/Google Chrome.app/Contents/MacOS/Google Chrome"
    },
  },

All 6 comments

You also need to have chrome installed on the machine in order for it to work.

I am having the same issue, and installing chrome made no difference.

This error comes from ChromeDriver. I'm not sure how exactly it looks up Chrome binary, but I'm pretty sure it searches in PATH, so please ensure it's available in PATH.

Closing as this is client environment issue and not Selenium.

If your Chrome is not installed in the standard location, you may have to explicitly specify it in your protractor.conf.js:

  capabilities: {
    'browserName': 'chrome',
    "chromeOptions": {
      binary: "/Applications/your_path/Google Chrome.app/Contents/MacOS/Google Chrome"
    },
  },

if anyone finds this, I had the same problem as @vpcom - and in MacOs I had a path string that was escaping the spaces- but apparently selenium expects a path string without the escaped spaces, like the above example.

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"
    }
  }
Was this page helpful?
0 / 5 - 0 ratings