Nightwatch.js without Java

Can I use Nightwatch.js without installing Java? There are official Selenium JavaScript bindings ( WebDriverJS , selenium-webdriver ). Is there a reason Java is required?

+7
source share
4 answers

There is currently documentation on the official website on how to do this.

I had some configuration problems, so I created a sample repository with working code:

https://github.com/zeljkofilipin/mediawiki-nightwatch

+4
source share

I serve the JavaScript community, so I try to run nightwatchjs locally without introducing Java myself. I am sure that if you start the remote Selenium Server, that remote instance must have a Java server on which the command is sent to the remote browser. For example: ChromeDriver.

However, I got the impression that you can connect a standard standard client to a standard WebDriver (ChromeDriver) locally without to create a selenium-server-standalone-2.xx.0.jar Java server. Since nightwatchJS is the first client I tried, it was very difficult to find a configuration where this would work, as all documentation indicates what says

He, what can I say: if you want nightwatch to start (and stop) the server for you during the tests ("start_process": true), it seems that this is necessary to start the Java server.

However, due to the large number of samples, if you want to run ChromeDriver yourself on the command line, thereby constantly working with it, I can run ChromeDriver without the standalone Java Selenium. CAVEAT: So far, only on OS X ... So, if 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 take this port (9515) and update your nightwatch.json to dictate that you want to use Chrome. I set the default value, but you can set up a Chrome-specific environment. Remove the "selenium" block from your nightwatch.json and now tell Nightwatch where it can find the running server. And what type of serving browser:

  "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 this method works for me; I can run nightwatch to control Chrome without a standalone Java Selenium server. Again, this is on OS X using ChromeDriver, which always works. I can't figure out how to get Nightwatch to control the start / stop of ChromeDriver without adding a separate Java Selenium server to the mix.

+5
source share

Well Nightwatch.js runs tests on the Selenium server. Selenium Server is a Java servlet.

So, to use Nightwatch.js you just need “indirectly” Java (it is not needed for Nightwatch.js, but for Selenium).

However, you can use different languages ​​like Selenium Client, since you can load different bindings of the WebDriver language here

+++++++++++++++++++ EDIT ++++++++++++++++++

These WebDrivers / bindings are independent of Nightwatch.js. You can use these WebDrivers / bindings without a Selenium server if your tests and your browser are running on the same computer. In this case, you do not need Java, since WebDriver runs the tests directly against the browser (this is described in more detail here )

Nightwatch.js, on the other hand, definitelly requires java because it needs a "Selenium-Standalone-Server", which is written in Java. As far as I know, there are no other implementations for other languages, so it is impossible to run it without java.

Nightwatch sends HTTP requests to the Selenium-Standalone-Server (here comes Java), and the server creates a session with the browser.

So, to summarize: No Java → No “Selenium-Standalone-Server” → No testing with Nightwatch.js

+1
source share

Exists:

Specify the following in the global.js file:

 const chromedriver = require('chromedriver'); module.exports = { before: function (cb) { chromedriver.start(); cb(); }, after: function (cb) { chromedriver.stop(); cb(); }, 

Go to nightwatch.conf.js specify the global path there

This way, selenium will be redirected through the Chromedriver without the need for selenium on your machine.

0
source share

All Articles