A guide to running multiple Protractor tests in parallel
On BrowserStack, you can run multiple Protractor tests at the same time across various browser, device and OS combinations. This is called Parallel Testing. Parallel Testing gives you the same benefits as running a multi-threaded application.
With Parallel Testing, you can run the same test on different browser/device combinations i.e. cross-browser testing, or run different tests on the same or different browser/device combinations. Parallel Testing will help you reduce the run time of your test suite, resulting in faster build times and faster releases.
git clone https://github.com/browserstack/protractor-browserstack
cd protractor-browserstack
npm install
protractor-browserstack/conf/parallel.conf.js
file as shown below:exports.config = {
'specs': [ '../specs/single.js' ],
'browserstackUser': 'YOUR_USERNAME',
'browserstackKey': 'YOUR_ACCESS_KEY',
// These capabilities would apply to all the combinations where the tests run in parallel
'commonCapabilities': {
'build': 'protractor-browserstack',
'name': 'parallel_test',
'browserstack.debug': 'true',
'browserName': 'Chrome'
},
maxSessions: 5, // You can change this to the maximum parallel limit for your BrowserStack account
// Every platform specific capability must be defined here. This example shows 4 desktop browsers where the tests would run
'multiCapabilities': [{
'browserName': 'Chrome'
},{
'browserName': 'Safari'
},{
'browserName': 'Firefox'
},{
'browserName': 'IE'
}],
// Code to mark the status of test on BrowserStack based on test assertions
onComplete: function (passed) {
if (!passed) {
browser.executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed","reason": "At least 1 assertion has failed"}}');
}
if (passed) {
browser.executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"passed","reason": "All assertions passed"}}');
}
}
};
// Code to support common capabilities
exports.config.multiCapabilities.forEach(function(caps){
for(var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i];
});
./node_modules/.bin/protractor conf/parallel.conf.js
multiCapabilities
variable as shown below:
"multiCapabilities": [{
"browser": "chrome",
"browser_version": "latest",
"os": "Windows",
"os_version": "10"
},{
"device": "iPhone 12 Pro",
"browser": "iPhone",
"os_version": "14"
},{
"browser": "safari",
"browser_version": "latest",
"os": "OS X",
"os_version": "Big Sur"
},{
"device": "Samsung Galaxy S20 Ultra",
"browser": "Android",
"os_version": "10.0"
}]
browserName: 'iPhone'
or browserName: 'android'
.capabilities
section of parallel.conf.js
file. (except the credentials which must be defined in the 'browserstackUser'
and 'browserstackKey'
variable in Protractor)
You can visit BrowserStack Automate Dashboard and see your test there once it has successfully completed.
With queuing, you can launch an additional number of parallel tests with different browser configurations that will be queued in a sequence. For instance, if you want to run 5 additional tests, apart from your subscribed limit of 2 parallel tests, BrowserStack will queue the additional 5 tests until one of the 2 initial tests finish, and a slot is available for execution. With queuing, you don’t need to worry about managing your test pipeline - we automatically take care of scheduling and execution for you.
With this feature, accounts up to 5 parallel tests can queue 5 tests. Beyond 5 parallel tests, an equivalent number of tests will be queued.
maxSessions: n
in the *.conf.js
file and Protractor would create a maximum of n
sessions at a time.
Contact our Support team for immediate help while we work on improving our docs.
Contact our Support team for immediate help while we work on improving our docs.
Thank you for your valuable feedback!