Nightwatch: ChromeDriver Could Run Locally without Java

Created on 23 Apr 2016  路  6Comments  路  Source: nightwatchjs/nightwatch

The wiki could be updated to be clearer that if a tester is going to run nightwatch locally, it could be run against an implementation of WebDriver directly without the need to leverage the Java Selenium Standalone Server. [See StackExchange [Nightwatch.js without Java](http://stackoverflow.com/a/36805178/2973538)...]

If chromeDriver is in $PATH (OS X):

$ chromedriver --url-base=/wd/hub
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 9515
Only local connections are allowed.

Note the port number. Remove the "selenium" block from nightwatch.json and tell nightwatch where to find the running, local WebDriver server:

  "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"]
            }
      },
    }
  }

The caveat is that I can't figure out how to get nightwatch to manage the server's lifetime; I have to start chromedriver from the command line outside of nightwatch's purview.

All 6 comments

You can use the chromedriver package from npm to manage the process in your global before and after hooks.

Still would like to see this documented. I'll do a pull request soon. But, until then, ... THAT SO WORKS!

After

% npm install --save-dev chromedriver

Changing test to:

module.exports = {
    '@disabled': false,

    before: function (client) {
        const args = [
            "--port=4444",
            "--url-base=/wd/hub"
        ];

        chromedriver.start(args);
        console.log('Open browser...');
        ...
    },

    after: function (client) {
        console.log('Closing down...');
        client.end();
        chromedriver.stop();
    },

I can remove the "selenium" block in nightwatch.json. It runs test fine; no Java.

It's also significantly faster in creating the session and opening the browser.

I will try to add this to the docs soon, in the meantime I guess this can be closed.

@beatfactor Did we ever add to the docs, I can't find a write up.

No, it's not there yet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maxgalbu picture maxgalbu  路  3Comments

Zechtitus picture Zechtitus  路  4Comments

danielbentov picture danielbentov  路  4Comments

manjero picture manjero  路  4Comments

Pieras2 picture Pieras2  路  3Comments