Nightwatch: test fails and two browsers are opened when starting the selenium server via nightwatch

Created on 11 Aug 2015  Â·  16Comments  Â·  Source: nightwatchjs/nightwatch

When I set nightwatch.json to start the selenium server two browser windows open and the tests fails.
screen shot 2015-08-10 at 9 34 59 pm

Most helpful comment

For reference, I found the cause of this, I don't understand why or how, but it's related to the beforeEach and afterEach blocks:

  // before each
  beforeEach: function(client, done) {
    Test.prototype.beforeEach.call(this, client, done);
    // done();
  },

  // after each
  afterEach: function(client, done) {
    Test.prototype.afterEach.call(this, client, done);
    // done();
  },

If you uncomment the done, in beforeEach, you get two browser. I would have said that's because the prototype call it by itself so I'm calling it twice, but removing done from there and calling it only by myself doesn't solve the issue.

Hopefully will save some headaches to some people

All 16 comments

What does your nightwatch.json file look like and the test file that you are executing?

I set up a new clean project with nightwatch for this since it also didn't work
with my tests. It's the default nightwatch.json with just the path to the
selenium server and "start_process" set to true. I run one of the example
files (the google test). I am on OS X 10.9.5, latest nightwatch version,
selenium-server-standalone-2.47.1.jar, happens on latest Chrome and latest
FF.

selenium server is in a bin folder in the project root, nightwatch.json is
in the project root too.

On Tue, Aug 11, 2015 at 6:18 AM, tcpatterson [email protected]
wrote:

What does your nightwatch.json file look like and the test file that you
are executing?

—
Reply to this email directly or view it on GitHub
https://github.com/nightwatchjs/nightwatch/issues/597#issuecomment-129869155
.

My java version (Java: Oracle Corporation 25.5-b02) seems to be the reason. In the output are both of these strings: var SENTINEL = ['Started org.openqa.jetty.jetty.Server', 'INFO - Selenium Server is up and running'];
The checkin which introduced both is this one: https://github.com/nightwatchjs/nightwatch/commit/d1495b02e283801139211d62a3e4446504933364

When I delete 'Started org.openqa.jetty.jetty.Server' it works as expected.

We will revert to the Java Version 24.65-b04 to avoid this problem for now.

Thanks, I had this issue as well!

I found out it was the java version. I updated java and now the tests pass

  • only one instance of chrome is opened.

On Tue, Sep 15, 2015 at 7:53 AM, mlennon3 [email protected] wrote:

Thanks, I had this issue as well!

—
Reply to this email directly or view it on GitHub
https://github.com/nightwatchjs/nightwatch/issues/597#issuecomment-140419116
.

Thanks, updating Java SDK 8 to the latest version helped! Only one instance of Firefox is now opened and properly closed.

how about closing this @frauklonk?

I recently hit this problem as well when running a slightly old version of Java 8 (1.8.0_05 on El Capitan).

Is checking for the 'Started org.openqa.jetty.jetty.Server' bit necessary for working with older versions of Java (and/or selenium)? Otherwise, I'd recommend either removing it from SENTINEL, or perhaps better, ensure that checkProcessStarted only calls its callback once after detecting startup.

(... Since the current check seems somewhat brittle. It wasn't that fun to hunt down the particulars of SENTINEL and startup firing twice...)

Hi, I'm having the same problem.
captura de pantalla 2016-04-10 a las 2 51 57 p m
I updated to the latest Java version. But the problem still happens.

This is my OS version:
captura de pantalla 2016-04-10 a las 2 54 33 p m

For reference, I found the cause of this, I don't understand why or how, but it's related to the beforeEach and afterEach blocks:

  // before each
  beforeEach: function(client, done) {
    Test.prototype.beforeEach.call(this, client, done);
    // done();
  },

  // after each
  afterEach: function(client, done) {
    Test.prototype.afterEach.call(this, client, done);
    // done();
  },

If you uncomment the done, in beforeEach, you get two browser. I would have said that's because the prototype call it by itself so I'm calling it twice, but removing done from there and calling it only by myself doesn't solve the issue.

Hopefully will save some headaches to some people

Was having the same issue. Thanks @Fire-Dragon-DoL for the tip

Thanks @Fire-Dragon-DoL , always a good idea to leave your solution, never know when someone will find it months, years, decades later. =) Worked like a charm!

Glad to help @pratiks , would love to understand the underlying issue though 😖

Same issue here and thanks for the tip @Fire-Dragon-DoL

I'm having the same problem, thanks for the workaround @Fire-Dragon-DoL. How about reopening the issue @frauklonk? Or would a new one be preferable?

This is a good workaround!
browser .end(function() { done() })

It's working even using parallel tests.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sgleonardoopitz picture sgleonardoopitz  Â·  3Comments

jvlaar picture jvlaar  Â·  4Comments

gary5 picture gary5  Â·  4Comments

chaseconey picture chaseconey  Â·  4Comments

willli666 picture willli666  Â·  3Comments