Nightwatch - Use chromedriver
Solution 1
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
Solution 2
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.
Related videos on Youtube
chrismillah
Updated on November 13, 2022Comments
-
chrismillah over 1 year
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.
- nightwatch.js tests running fine in FF
- downloaded chromedriver (
npm install chromedriver -g
) and alsonpm install chromedriver
into my nightwatch project directory -
went 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 errorERROR 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
-
chrismillah almost 9 yearsThanks @juhi, didnt realzie that about selenium.jar file. But ended up being able to fix it by not using the default nightwatch.json file that was already in my project, created a new one on the root and all worked fine.
-
chrismillah almost 9 yearsthanks for your input @juhi - it does help me, but the question was originally about using chromedriver.
-
Juhi Saxena almost 9 yearsNo problem , but I think I have also mentioned how to give chrome driver path in nightwatch.json and also how to run group with chrome. Anyways no problem. Thanks for replying
-
Praveen almost 8 yearsSaved time.. Thanks mate
-
Roobie over 6 years@ravi - thanks for sharing your solution. Have you tried running nigthwatch tests on a chrome node in a grid setting? If so, to do you configure nightwatch? I can't any documentation on this at all
-
ravi about 6 yearsUnfortunately I didn't find any Solution for Grid,But there is an alternate solution i.e By Using Docker I am trying to get this working I will update you if this is Successful
-
ravi about 6 yearsHi Roobie got the solution to run the night watch on selenium Grid