使用不同的窗口大小运行量角器测试? [英] Run protractor tests with different window sizes?
问题描述
我想启动 4 个不同的 chrome 窗口以在 4 个分辨率上运行相同的测试.——
I want to start 4 different chrome windows to run the same tests on 4 resolutions. –
我知道量角器有一个叫做 multiCapabilities 的功能,我知道你可以像这样设置窗口大小:browser.manage().window().setSize(320, 480);
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
推荐答案
我想到的一个非常简单的解决方案是使用 开关在测试文件中创建一个
使您的测试以不同的分辨率运行 4 次.for
循环
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.
在规范的开头:
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(){...};
});
这篇关于使用不同的窗口大小运行量角器测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!