【发布时间】:2019-03-27 15:32:07
【问题描述】:
我的问题涉及涉及响应式网络应用的端到端测试场景。我已经为页面编写了测试场景,以根据屏幕分辨率使用不同的测试用例进行测试。我正在使用数组变量来存储链接到同一元素的不同选择器,例如:
it('should display the log in page', function () {
gVar.signInButton = element(by.css(gVar.signInButtonSelector[gVar.SelectedMode]));
gVar.signInButton.click().then(function(){
expect(element(by.css(gVar.titleLoginPageSelector[gVar.SelectedMode])).getText()).toEqual(gVar.titleLoginPage[i]);
});
这里我试图选择登录页面标题来测试它。根据分辨率不同,只有选择器不同,我将它们存储在数组中...
在我的 conf.js 中,我有一个参数变量,我在命令行中使用它来设置我想要使用的配置:
exports.config = {
//...
params:{
resolutionConfig:'default'
},
//...
}
运行命令可以去:
protractor conf.js --params.resolutionConfig=Classic 或
protractor conf.js --params.resolutionConfig=Mobile 或
protractor conf.js --params.resolutionConfig=Tablet ...
(然后我有一个匹配表来把这个参数和上面的整数值关联起来:gVar.SelectedMode)
我现在想做的是为我的浏览器设置不同的分辨率值,为我正在测试的每个 resolutionConfig 参数值设置一个不同的值。到目前为止,我知道如何使用硬编码值设置该分辨率:
exports.config = {
//...
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--window-size=100,100'] // THIS!
}
//...
}
我听说过运行并行测试的“多能力”,但这并不是我想要的……是否可以将分辨率参数设置为变量并为其添加逻辑?比如:
if(resolutionConfig) is "mobile" then: ['--window-size=xx,xx'];
if(resolutionConfig) is "tablet" then: ['--window-size=yy,yy'];
【问题讨论】:
标签: testing configuration protractor