Is there a way to run protractor tests in parallel by opening a browser instance for each test?
Solution 1
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 ;)
Solution 2
To split tests between two browsers,
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 2
},
Solution 3
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.
Ziwdigforbugs
Updated on June 15, 2022Comments
-
Ziwdigforbugs about 2 years
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?
-
Ziwdigforbugs over 10 yearsThanks for you answer, my concern is not about distributing tests between different browser, at lease not yet. What I would like to do is to run tests in parallel as oppose to one after the other using the same browser in order to avoid synchronisation issue.
-
glepretre over 10 yearsDid you try to set the same browser in
multiCapabilities
? I tested it, it's working for me :) -
Ziwdigforbugs over 10 yearsI have tried this now and it run two instances of firefox but it run the same test twice what I would like to do is run two different tests in parallel. Do you mind we continue this in cha?
-
glepretre over 10 yearsNo problem to move to chat for me, but I don't know how to do it manually :/ The support sharding feature request seems to be exactly what you want to do, no?
-
Ziwdigforbugs over 10 yearsI don' know neither!! well now I am able to share my tests between browsers. However I am facing issues when running many tests one after one in the same browser only the first tests runs.
-
Ziwdigforbugs over 10 yearsNo in fact the first tests run with all its subtests 'it' then the second starts and blocks after logging in. Then I get element ni visible error.
-
glepretre over 10 years
-
glepretre over 10 yearsif this question is solved, could you accept the answer please? :)