Matthew Serna
Matthew Serna

Reputation: 13

Issues running nightwatch + selenium on local docker pipelines

I am having issues when running a simple nightwatch test file on my local Docker image. I am trying to figure out why selenium does not want to run the local tests. If anyone has figured this out, any help would be much appreciated. Thanks!

Here is my test file:

nw-example.test.js

module.exports = {
  'End-to-end all browsers' : function (browser) {
    browser
      .init('http://localhost:3000/')
      .setValue('#loginForm-username', '')
      .setValue('#loginForm-password', '')
      .pause(2000)
      .click('#loginForm-submit')
      .perform(function(done){
        console.log('Done testing')
        done()
      })
      .pause(3000)
      .assert.containsText('#app','Welcome,');
  }
};

Here is my nightwatch.json file:

{
  "src_folders" : ["tests"],
  "output_folder" : "reports",
  "custom_commands_path" : "",
  "custom_assertions_path" : "",
  "page_objects_path" : "",
  "globals_path" : "",

  "selenium" : {
    "start_process" : true,
    "server_path" : "",
    "log_path" : "",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./usr/local/bin/chromedriver",
      "webdriver.gecko.driver" : "./usr/local/bin/geckodriver",
      "webdriver.edge.driver" : "",
      "webdriver.safari.driver" : ""
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost:3000",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName" : "chrome",
        "javascriptEnabled" : true,
        "marionette" : true,
        "acceptSslCerts" : true
      }
    },

    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions" : {
          "args" : ["headless", "--no-sandbox"]
        }
      }
    },

    "firefox" : {
      "desiredCapabilities": {
        "browserName": "firefox"
      }
    },

    "edge" : {
      "desiredCapabilities": {
        "browserName": "MicrosoftEdge"
      }
    },

    "safari" : {
      "desiredCapabilities": {
        "browserName": "safari",
        "javascriptEnabled": true
      }
    }
  }
}

And the errors I am getting:

root@2b755e5a6174:/vital-webapp/src/__tests__# nightwatch nw-example.test.js 

[Nw Example Test] Test Suite
================================

Running:  End-to-end all browsers
20:13:49.642 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@2465e6e1
20:13:49.643 INFO - /session: Executing POST on /session (handler: BeginSession)
20:13:49.646 INFO - Capabilities are: Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true, marionette: true, name: Nw Example Test}
20:13:49.646 INFO - Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true, marionette: true, name: Nw Example Test} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881) on port 4516
Only local connections are allowed.
20:13:59.737 WARN - timeout
java.net.SocketTimeoutException: timeout

Upvotes: 1

Views: 550

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193108

The error says it all :

20:13:49.646 INFO - Capabilities are: Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true, marionette: true, name: Nw Example Test}
20:13:49.646 INFO - Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true, marionette: true, name: Nw Example Test} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881) on port 4516
Only local connections are allowed.
20:13:59.737 WARN - timeout
java.net.SocketTimeoutException: timeout

While you configured ChromeDriver you have suplied the following desiredCapabilities :

  "desiredCapabilities": {
    "browserName" : "chrome",
    "javascriptEnabled" : true,
    "marionette" : true,
    "acceptSslCerts" : true
  }

ChromeDriver have no such capability as "marionette" which is set to true.

Remove the capability "marionette" : true and execute your @Test

Upvotes: 1

Related Questions