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"
}
},
}
}
-
2With that error message, I'm inclined to say that you need to have an active Selenium session to run your test.Kate Paulk– Kate Paulk2016年12月19日 14:48:25 +00:00Commented Dec 19, 2016 at 14:48
-
OK, thank you. My first understanding told me that chrome driver would replace the selenium server, which is why I was confused.RSeidelsohn– RSeidelsohn2016年12月19日 23:05:24 +00:00Commented Dec 19, 2016 at 23:05
-
2Selenium Standalone Server can be used to define a 'hub' and 'nodes'. The hub distributes tests and the nodes run them (using WebDriver).kirbycope– kirbycope2016年12月21日 17:08:35 +00:00Commented Dec 21, 2016 at 17:08
-
stackoverflow.com/questions/27225118/… hope it help you @RSeidelsohnShailendra Rathore– Shailendra Rathore2017年01月02日 06:26:09 +00:00Commented Jan 2, 2017 at 6:26
1 Answer 1
From Selenium Documentation:
You may, or may not, need the Selenium Server, depending on how you intend to use Selenium-WebDriver. If your browser and tests will all run on the same machine, and your tests only use the WebDriver API, then you do not need to run the Selenium-Server; WebDriver will run the browser directly.
There are some reasons though to use the Selenium-Server with Selenium-WebDriver.
You are using Selenium-Grid to distribute your tests over multiple machines or virtual machines (VMs). You want to connect to a remote machine that has a particular browser version that is not on your current machine. You are not using the Java bindings (i.e. Python, C#, or Ruby) and would like to use HtmlUnit Driver
-
Which brings up a question if Nightwatch can use Webdriver API. Judging from it having
server_path
andstart_process
options, it can't. Or am I wrong? Come to think of it which tools do you know that can? Does starting Selenium Server means Webdriver protocol (or what's its name) can't be used?x-yuri– x-yuri2018年04月19日 16:31:52 +00:00Commented Apr 19, 2018 at 16:31
Explore related questions
See similar questions with these tags.