Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the "webdriver.chrome.driver" property with Protractor

I am getting this error:

[01:10:42] E/launcher - The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
[01:10:42] E/launcher - WebDriverError: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
    at Object.checkLegacyResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

I need to set the webdriver.chrome.driver property, but I can't find any docs on how to do this with Protractor, does anyone know?

If I had this to my protractor.conf.js:

 chrome:{
    driver:  process.env.CDT_CHROMEDRIVER || '/usr/local/bin/chromedriver'
  },

then I get this error:

unknown error: no chrome binary at /usr/bin/google-chrome
like image 739
Alexander Mills Avatar asked Jan 24 '18 01:01

Alexander Mills


People also ask

How can we set the system property for ChromeDriver?

Any of these steps should do the trick: include the ChromeDriver location in your PATH environment variable. (Java only) specify its location via the webdriver.chrome.driver system property (see sample below) (Python only) include the path to ChromeDriver when instantiating webdriver.Chrome (see sample below)

How do I change chrome properties in Selenium?

Initially, you need to set the path to the chromedriver.exe file using set property method since you are using Chrome Browser for testing. You need to set the path to CRX File to add extensions method. Then you need to create an object of Chrome Desired Capabilities in Selenium class and pass it to web driver instance.

How do I update Chrome Webdriver in protractor?

Run sudo npm install -g protractor, and then start your webdriver server, last step do "sudo webdriver-manager update". Now you should be able to invoke your browser :) Save this answer.

What is WebDriverManager ChromeDriver () setup ()?

WebDriverManager is an open-source Java library that carries out the management (i.e., download, setup, and maintenance) of the drivers required by Selenium WebDriver (e.g., chromedriver, geckodriver, msedgedriver, etc.) in a fully automated manner.


1 Answers

Case 1 When you set DirectConnet to true in protractor conf file

Option 1: set in protractor conf file

exports.config = {
  chromeDriver: './node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver'
};

Note: If use relative path, it relatived to the config file folder

Option 2: pass-in in protractor command line, it will overwrite the one in conf file.

protractor conf.js --chromeDriver='./node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver'

Note: If use relative path, it relative to the foler where command executed under, calculated by process.cwd()

Case 2 When you set selenuimAddress to local/remote selenium server

Option 1: use npm package webdriver-manager to help to update and start selenium server, it can calculate the webdriver path automatically, no need you to tell where is.

Option 2: start selenium server by java command and specify -Dwebdriver.chrome.driver=absolute path of chromedriver

Case 3 When you set seleniumAddress to selenium grid
the only chance you can specify webdriver.chrome.driver is when execute register cmd to register selenium node to selenium hub, you can't do anything in other place.

like image 121
yong Avatar answered Sep 20 '22 01:09

yong