I want to start 4 different chrome windows to run the same tests on 4 resolutions. –
I know protractor has a feature called multiCapabilities, and I know you can set the window size like this:
browser.manage().window().setSize(320, 480);
But I don't really find a way to combine these 2. Or is there an easier way to create this behaviour
A very simple solution that comes in my mind would be to create a for
loop in your test file with a switch
to make your tests running 4 times with a different resolution.
At the beginning of your specs:
describe('myApp', function () {
for (var i = 0; i < 4; i++) {
switch (i) {
case 0:
//set resolution 1
browser.manage().window().setSize(320, 480);
break;
case 1:
//set resolution 2
browser.manage().window().setSize(600, 800);
break;
case 2:
//set resolution 3
browser.manage().window().setSize(768, 1024);
break;
case 3:
//set resolution 4
browser.manage().window().setSize(1080, 1920);
break;
default:
return;
}
}
// beforeEach() {...};
// it('should do something', function(){...};
});
As for me, the best way is to add multiCapabilities
in config:
multiCapabilities: [{
'browserName': 'chrome',
'chromeOptions' : {
args: ['--lang=en',
'--window-size=800,800']
},
specs: ['spec.js']
},{
'browserName': 'chrome',
'chromeOptions' : {
args: ['--lang=en',
'--window-size=350,650']
},
specs: ['spec.js']
// and so on
}]