- Nightwatch: 1.0.18.
- Selenium standalone: 3.141.59.
- Chromedriver: 2.46.
- Install chromedriver:
# Inside project
npm install chromedriver --save-dev
# Globally
# npm install -g chromedriver --save-dev
- Create the nightwatch's config file:
{
"src_folders" : ["./tests"],
"output_folder": "./tests/reports",
"selenium": {
"start_process": true,
"server_path": "./bin/selenium-server-standalone-3.141.59.jar",
"cli_args" : {
"webdriver.chrome.driver" : "./node_modules/.bin/chromedriver"
}
},
"test_settings" : {
"default" : {
"webdriver": {
"start_process": false,
"start_session": false,
"host": "127.0.1.1",
"port": 9515,
"server_path": "./node_modules/.bin/chromedriver",
"log_path": "./browser-test/logs/"
},
"screenshots" : {
"enabled" : true,
"on_failure" : true,
"on_error" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true,
"chromeOptions": {
"args": [
"start-maximized"
]
}
}
}
}
}
EXPLANATION
-
We configure selenium to use npm chromedriver.
-
Inside test_settings we add all settings to default because we will only use Chrome.
-
Now, we configure webdriver for Chrome. It's important that
start_process
andstart_session
was false to avoid conflicts with selenium server. host has our local ip (localhost), in addition, with port we configure the chromedriver port9515
by default. Important, If you installed chromedriver globally change theserver_path
and type onlychromedriver
instead of the full path. -
In desiredCapabilities you can configure how Chrome works. In this example we enabled javascript, the ssl certs and we start Chrome maximized.