I'm new to Selenium and Nightwatch and installed selenium-webdriver first, then chromedriver and finally I installed Nightwatch (because the syntax looks nice to me). Now when I want to run a single test with nightwatch, I always get this result:
> ./node_modules/nightwatch/bin/nightwatch -t nightwatch-node-scripts/test.js
[Test] Test Suite
=====================
Running: Demo test Google
Error processing the server response:
unknown command: wd/hub/session
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value: -1, error: 'Unexpected token u in JSON at position 0' }
The chromedriver is running and listening on port 9515:
> lsof -Pnl +M -i4 | grep 9515
chromedri 6489 1000 8u IPv4 867952 0t0 TCP 127.0.0.1:9515 (LISTEN)
which is the one I use in my pretty basic nightwatch.json:
{
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "",
"globals_path": "",
"selenium": {
"start_process": false,
"server_path": "",
"log_path": "",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "/usr/local/bin/chromedriver",
"webdriver.gecko.driver": "",
"webdriver.edge.driver": ""
}
},
"test_settings": {
"default": {
"launch_url": "http://localhost",
"selenium_port": 9515,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions" : {
"args" : ["--no-sandbox"]
},
"acceptsCerts" : true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome"
}
},
}
}