So i saw a similar question on stack here but it did not have an accepted answer nor did it provide me with the information i needed..
I am trying to use 'chromedriver' because 'selenium-webdriver' requires a FF version <= 28.
What i've done so far.
npm install chromedriver -g
) and also npm install chromedriver
into my nightwatch project directorywent to nightwatch/bin/nightwatch.json
and edited the following code
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/usr/local/bin/chromedriver", <= added this - is this the binary?
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}},
also tried to update the settings for selenium to have a start_process=true and server_path
"selenium" : {
"start_process" : true,
"server_path" : "../selenium-server-standalone-2.39.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/usr/local/bin/chromedriver",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
Not sure if im pointing to the proper chromedriver file/folder
also edited the test settings
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "chrome", <= changed this from ff to chrome
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
If i go to run the test (without a -e <browser>
) e.g. nightwatch -g <group>
, it launches fine in FF and runs..
If i try to specify the chrome browser (-e chrome
) nightwatch -g <group> -e chrome
i get the following error
ERROR There was an error while starting the test runner:
Error: Invalid testing environment specified: chrome
at Object.CliRunner.parseTestSettings (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:354:15)
at Object.CliRunner.init (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:31:8)
at module.exports.runner.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:512:19)
at /usr/local/lib/node_modules/nightwatch/bin/runner.js:9:16
at module.exports.cli.cli (/usr/local/lib/node_modules/nightwatch/lib/index.js:504:7)
at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
The questions i have are:
How do i point to the binary file (not sure which it is)
Are my settings in nightwatch.js correct? How is it running in FF if i changed the test_settings 'browserName = Chrome"?
Am i missing something here?
Thanks in advance
Nightwatch. js framework is a Selenium-based test automation framework, written in Node. js and uses the W3C WebDriver API (formerly Selenium WebDriver).
It provides capabilities for navigating to web pages, user input, JavaScript execution, and more. ChromeDriver is a standalone server that implements the W3C WebDriver standard. ChromeDriver is available for Chrome on Android and Chrome on Desktop (Mac, Linux, Windows and ChromeOS).
See https://www.chromium.org/developers/version-numbers for more details. Each version of ChromeDriver supports Chrome with matching major, minor, and build version numbers. For example, ChromeDriver 73.0. 3683.20 supports all Chrome versions that start with 73.0.
First you said
I am trying to use 'chromedriver' because 'selenium-webdriver' requires a FF version <= 28.
Its because you are using selenium-server-standalone-2.39.0.jar (Old jar) Please download new one from here selenium-server-standalone-2.45.0.jar Second Download chrome driver from here Chromedriver basis on your environment
Third update your nightwatch.json with below code
{
"src_folders": [
"tests"
],
"selenium": {
"start_process": false,
"server_path": "bin/selenium-server-standalone-2.45.0.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "bin/chromedriver",
"webdriver.ie.driver": ""
}
},
"test_settings": {
"default": {
"launch_url": "http://127.0.0.1/",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
Fourth run your group with nightwatch -g -e chrome
Hope It will solve your problem.
Make sure to create a new nightwatch.json file in the root of your project.
The mistake i made was trying to use the nightwatch.json file that came with the package downlaoded from http://nightwatchjs.org/ that resided in nightwatch-0.6.11/bin/nightwatch.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With