In my earlier post, I talked about how to configure protractor to run on Firefox with single capabilities. however what if one needs to run on multiple browsers (whether if it is sequentiallly or parallely). That will be the topic of this post.
So follow the conventions from the earlier post, we will use a separate file that contains the configuration (browserConfig.js):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
const chrome = { 'browserName': 'chrome', 'chromeOptions': { 'args': [ 'disable-infobars', ] } }; const firefox = { 'browserName': 'firefox', 'marionette': true, }; const multiBrowsers = [ chrome, firefox, ] module.exports = { chrome, firefox, multiBrowsers } |
Here we added mulitBrowsers to include both chrome and firefox to be used later. And to enable multi capability we will add the following to the file protractor.conf.js:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
const browserConfig = require('./browserConfig'); exports.config = { // <other code and configuration goes here> // This is needed to run tests on firefox // This configuration does not interfere with operation of other browser directConnect: true, // The following line enable multi capabilities meaning running tests on more than // one browser: multiCapabilities: appiumCapabilities['multiBrowsers']; // This is needed to run sequentially in multiCapability, i.e. one browser at a time maxSessions: 1; }; |
Notice here we are retrieve mulit-capabilities from file browserConfig.js
, and assigned to mutiCapabilities
instead capabilities
.
Also note that we are adding another parameter called maxSessions
, this limits the number of sessions is allowed to run at a time, if we want to run one browser at a time, we will want to limit the number of sessions to 1. If we want to run 2 ore more at the same time in paralle, we will want to increase this value to the desired value.
This concludes this post, and hope it will be helpful to you.
References:
[1] https://sqa.stackexchange.com/questions/18105/how-to-run-e2e-tests-on-multiple-browsers-in-series
[3] https://github.com/angular/protractor/blob/master/docs/browser-setup.md