Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to run protractor tests in parallel by opening a browser instance for each test?

I am facing synchronisation issues with my protractor tests and I would like to run my tests in parallel in contrast to my actual settings. In fact at the moment my tests run one after the other. I know how to this with TestsNG not sure how to do it with Jasmin Framework?

like image 278
Ziwdigforbugs Avatar asked Mar 05 '14 13:03

Ziwdigforbugs


3 Answers

To split tests between two browsers,

  capabilities: {
    browserName: 'chrome',
    shardTestFiles: true,
    maxInstances: 2
  },
like image 157
Prashanth Sams Avatar answered Sep 18 '22 13:09

Prashanth Sams


Since 0.19.0 version of Protractor, you can run tests in parallel using the multiCapabilities option:

protractor.conf.js

multiCapabilities: [{
  'browserName': 'chrome'
}, {
  'browserName': 'chrome'
}]

from Browser setup - Protractor docs

This issue seems to fit your case.

For now, Protractor doesn't allow to set Webdriver maxSessions option, there is a more global discussion to include this feature among others.

EDIT: multiCapabilities was introduced to run tests in parallel under different browsers, but in your case, you can use it to run multiple instances of the same ;)

like image 41
glepretre Avatar answered Sep 21 '22 13:09

glepretre


multiCapabilities: [
    {
        "browserName": "chrome",        
        shardTestFiles: true,
        maxInstances: 2,
        specs: ['login.js', 'login2.js', 'login.js', 'login2.js']
    },
    {
        "browserName": "firefox",
        "count": 1
        specs: ['login2.js']
    },
],

You can use both "count" as well "maxInstances" This is what worked best for me ..

            "browserName": "chrome",        
            shardTestFiles: true,
            maxInstances: 2,
            specs: ['login.js', 'login2.js', 'login.js', 'login2.js']

this would run 4 tests divided equally(or may not equally) in two different chrome browsers.

like image 26
Neelendu Shekhar Avatar answered Sep 18 '22 13:09

Neelendu Shekhar