Is it possible to use Nightwatch.js without installing Java? There are official Selenium JavaScript bindings (WebDriverJS, selenium-webdriver). Is there a reason Java is required?
I am catering to a JavaScript community so I am trying to run nightwatchjs locally without introducing Java myself. I am certain that if you run a remote Selenium Server, that remote instance has to have the Java server running to pass off commands to the remote browser-specific driver. E.g.: ChromeDriver.
That said, I was under the impression that one could connect a standard client directly to a standard WebDriver (ChromeDriver) locally without having to stage the Java selenium-server-standalone-2.xx.0.jar server. With nightwatchJS being the 1st client I have tried, it was very hard to find a configuration where that would work since all the documentation indicates what Nate Stone is saying above. All examples that I have seen indicate that the location of the selenium-server-standalone-2.xx.0.jar needs to be stipulated:
selenium": {
"start_process": true,
"server_path": "lib/selenium-server-standalone-2.53.0.jar",
"cli_args" : {
"webdriver.chrome.driver" : "/Users/greg.kedge/bin/chromedriver"
},
"log_path": "integration/log" }
He's what I can say: if you want nightwatch to start (and stop) the server for you for the duration of the tests ("start_process": true), it does seem to be necessary to run the Java server.
However, through much trial, if you want to start the ChromeDriver on your own on the command line, thereby having it up all the time, I can run the ChromeDriver without the Java Selenium standalone. CAVEAT: Only attempted on OS X so far... So, assuming ChromeDriver is in your $PATH:
% chromedriver --url-base=/wd/hub
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 9515
Only local connections are allowed.
Now grab that port (9515) and update your nightwatch.json to dictate you want to use Chrome. I am setting the default, but you could set up a Chrome-specific environment. Remove the "selenium" block from your nightwatch.json altogether and now tell nightwatch where it can find a running server AND what type of browser that is serving:
"test_settings": {
"default": {
"launch_url": "http://localhost:8888/",
"selenium_host": "127.0.0.1",
"selenium_port": "9515",
"silent": true,
"firefox_profile": false,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"__commentOut: chromeOptions" : {
"args" : ["start-fullscreen"]
}
},
}
}
Using it this way works for me; I can run nightwatch to drive Chrome without a Java Selenium standalone server in-play. Again, this is on OS X using a ChromeDriver that is always running. I can't figure out how to get nightwatch to manage starting/stopping the ChromeDriver without adding the Java Selenium standalone server to the mix.
There is now documentation on the official site on how to do it.
I had some trouble with the configuration, so I have created a sample repository with working code:
https://github.com/zeljkofilipin/mediawiki-nightwatch
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