0

Issue :

We are running NightWatch tests in Jenkins, and once in a while, we get this error :

[0;31mConnection refused! Is selenium server started?
[0m[0;90m{ Error: socket hang up
    at createHangUpError (_http_client.js:253:15)
    at Socket.socketCloseListener (_http_client.js:285:23)
    at emitOne (events.js:101:20)
    at Socket.emit (events.js:188:7)
    at TCP._handle.close [as _onclose] (net.js:501:12) code: 'ECONNRESET' }[0m

The fix recommended in other places is already there : export DBUS_SESSION_BUS_ADDRESS=/dev/null

This is how we run the tests :

sudo npm install selenium-standalone -g

selenium-standalone install --version=3.0.1 --baseURL=https://selenium-release.storage.googleapis.com --drivers.chrome.version=2.28 --drivers.chrome.baseURL=https://chromedriver.storage.googleapis.com --basePath=bin 

sudo npm install nightwatch@0.9.13 -g && nightwatch --tag sanity --retries 1 --suiteRetries 1 

Rebuilding the job usually run the tests successfully. Softwares' version:

Chrome : 57

Chrome driver : 2.28

Selenium: 3.0.1

NightWatch : 0.9.13 (bumped down from 0.9.14 in case the latest release had a bug but no change.)

Jenkins : 1.6x

Ubuntu : 16.04

Using xvfb

Error Scenarios

The tests were running fine until about 2 weeks ago, just when we switched to Ubuntu 16, but that day it started happening on Ubuntu 14 too.

It especially happens when we've just spun a new Jenkins slave (on AWS cloud.) Happens more often at the very start of the test run but sometimes it happens in the middle of the run too.

I'll appreciate any help or pointers!

Beenish Khan
  • 1,571
  • 10
  • 18

2 Answers2

0

I have the same problem yesterday. Maybe you can change the version of Chrome. such as Chrome:55.

when i changed the version of chrome the selenium

HEXB
  • 61
  • 1
  • 7
0

We ran into a similar issue, but our error message was more specific:

Selenium is already running on port ####. Or some other service is.

The solution was to use the Jenkins Port Allocator Plugin to assign an available port number to an environment variable.

From there, we were able to set the port number in our globals.js like this (with a default of 4444 for running locally):

portNumber: process.env.PORT_NUMBER || 4444,

In our nightwatch.conf.js file, we used a lodash template to replace values in our nightwatch.json like this:

fs = require('fs'),
_ = require('lodash'),
template = _.template(fs.readFileSync('./nightwatch.json', 'utf8')),
settingsString,
settings;

settingsString = template({
    portNumber: globals.portNumber
});

settings = JSON.parse(settingsString);
module.exports = settings;

Finally, in our nightwatch.conf file, we set the values for all port references to:

"<%= portNumber %>"