我需要在会话之前安装args。在特定的标签上必须传输特定的屏幕分辨率。我尝试实现beforeSession,但是启动会话时chromeOptions.args中没有必要的arg。
我尝试了两个版本:
1。 beforeSession:
beforeSession: function(){
if(argv.tags ===("@virtualFront")){
exports.config.capabilities[0].chromeOptions.args.push('--window-size=1080,1920');
} else{
exports.config.capabilities[0].chromeOptions.args.push(' --start-maximized');
}
console.log("it is from config beforeSession: "+exports.config.capabilities[0].chromeOptions.args);
},
suite.cucumber.wdio.conf:
browserName: 'chrome',
chromeOptions: {
args: ['--incognito',],
binary: '/Program Files (x86)/Google/Chrome/Application/chrome.exe'
},
BeforeSession:
beforeSession:function(){
if(argv.tags ===("@virtualFront")){
argv.optionChrome = '--window-size=1080,1920';
} else{
argv.optionChrome=' --start-maximized';
}
console.log("it is from config beforeSession: "+exports.config.capabilities[0].chromeOptions.args);
},
suite.cucumber.wdio.conf:
{
browserName: 'chrome',
chromeOptions: {
args: ['--incognito',argv.optionChrome, ],
binary: '/Program Files (x86)/Google/Chrome/Application/chrome.exe'
},
当我使用2个版本args分配为null
答案 0 :(得分:0)
解决方案是将脚本添加到suite.cucumber.wdio.conf的开头:
let chromeOpts = ['--incognito'];
if (argv.tags ==="@virtualFont"){
chromeOpts +=` --window-size=1080,1920`
}else chromeOpts +=` --start-maximized`;
和:
chromeOptions: {
args: [ chromeOpts, ],
binary: '/Program Files (x86)/Google/Chrome/Application/chrome.exe'
//for windows7
},