Nightwatch: Start two browsers

Created on 20 Feb 2014  路  8Comments  路  Source: nightwatchjs/nightwatch

@beatfactor
Do you know if there is a way to start 2 browsers ? I mean with only one command
For example if I need to test a chat, is there a way to test it with a second client ?

I did it with selenium but didn't find a way to do it using nightwatch

enhancement

Most helpful comment

Why was this issue closed?

All 8 comments

_Interesting!_

I don't believe nightwatch supports this yet, testing of two browsers at the same time. What if you had two different nightwatch sessions running at the same time and passed in a different environment with the --env operation?

No, it doesn't but it's certainly something to consider for the future.

On Fri, Feb 21, 2014 at 3:26 PM, jordan112 [email protected] wrote:

I don't believe nightwatch supports this yet, testing of two browsers at
the same time. What if you had two different nightwatch sessions running at
the same time and passed in a different environment with the --env
operation?

Reply to this email directly or view it on GitHubhttps://github.com/beatfactor/nightwatch/issues/49#issuecomment-35734143
.

@beatfactor Yes that would be a really interesting feature. Btw it was possible to do it with the selenium protocol so maybe we can see how implement the feature
@jordan112 To do it I need to open another terminal to start a new nightwatch runner... That's a problem because running a new terminal depend on your system configuration.

I think it might be possible using the cluster module and spawning a new
worker for each target browser.

On Fri, Feb 21, 2014 at 3:52 PM, Alexandre Croix
[email protected]:

@beatfactor https://github.com/beatfactor Yes that would be a really
interesting feature. Btw it was possible to do it with the selenium
protocol so maybe we can see how implement the feature
@jordan112 https://github.com/jordan112 To do it I need to open _another
terminal_ to start a new nightwatch runner... That's a problem because
running a new terminal depend on your system configuration.

Reply to this email directly or view it on GitHubhttps://github.com/beatfactor/nightwatch/issues/49#issuecomment-35736660
.

Ok I did a test with cluster and workers, that's working !
So first, thanks !

Here is the poc:

var cluster = require('cluster');
var exec = require('child_process').exec;

if (cluster.isMaster) {

    cluster.fork().on('online', function () {
        exec('./nightwatch local -e chrome -t tests/chat/client1.js', function (error, stdout, stderr) {
            console.log('stdout: ' + stdout);
            if (error !== null) {
                console.log('exec error: ' + error);
            }
        });

        this.kill();
    });

    cluster.fork().on('online', function () {
        exec('./nightwatch local -e chrome -t tests/chat/client2.js', function (error, stdout, stderr) {
            console.log('stdout: ' + stdout);
            if (error !== null) {
                console.log('exec error: ' + error);
            }
        });

        this.kill();
    });
}

Possible next step can be :

  • Target browsers we want to use

    • with nightwatch cli ?

  • If the user want to use "multibrowser"

    • new workers for each target browser

    • each workers start a new nightwatch runner

@beatfactor What do you think ?

Yes, this is a good start.
On Feb 24, 2014 5:00 PM, "Alexandre Croix" [email protected] wrote:

Ok I did a test with cluster and workers, that's working !
So first, thanks !

Here is an example:

var cluster = require('cluster');var exec = require('child_process').exec;
if (cluster.isMaster) {

cluster.fork().on('online', function () {
    exec('./nightwatch local -e chrome -t tests/chat/client1.js', function (error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        if (error !== null) {
            console.log('exec error: ' + error);
        }
    });

    this.kill();
});

cluster.fork().on('online', function () {
    exec('./nightwatch local -e chrome -t tests/chat/client2.js', function (error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        if (error !== null) {
            console.log('exec error: ' + error);
        }
    });

    this.kill();
});}

Possible next step can be :

  • Target browsers we want to use

    • with cli ?

    • If the user want to use "multibrowser"

    • new workers for each target browser

    • each workers start a new nightwatch runner

@beatfactor https://github.com/beatfactor What do you think ?

Reply to this email directly or view it on GitHubhttps://github.com/beatfactor/nightwatch/issues/49#issuecomment-35900944
.

Why was this issue closed?

Was this page helpful?
0 / 5 - 0 ratings