是否可以在运行时传递浏览器堆栈功能?下面的功能列表已在配置文件中传递。每次运行脚本时,我都会注释其余的浏览器,并使用量角器Cucumber.Browserstackconfig.js运行。是否可以仅运行特定的设备或浏览器而不评论其他功能。我还尝试了多种功能,其中脚本在提到的所有设备上运行。有人可以为此提供解决方案吗?
'os_version' : '5.0',
'device' : 'Samsung Galaxy S6',
'real_mobile' : 'true',
'browserstack.local' : 'false',
'resolution':'800x600',
'acceptSslCerts': true
'deviceOrientation' :'landscape'
'os_version' : '11.2',
'device' : 'iPhone 6',
'real_mobile' : 'true',
'browserstack.local' : 'false',
'browserName': 'Chrome',
'browser_version': '68.0',
'acceptSslCerts': true,
'resolution':'800x600',
'os_version' : '9.1',
'device' : 'iPad Mini 4',
'browserstack.local' : 'false',
'acceptSslCerts': true
'os': 'Windows',
'os_version': '10',
'browserName': 'IE',
'browser_version': '11.0',
'resolution': '1024x768',
'acceptSslCerts': true,
答案 0 :(得分:0)
1)准备文件capabilities.js
来保留您的所有浏览器功能,并按如下所示导出get()
函数:
var capabilitiesList = {
'S6': {
'os_version': '5.0',
'device': 'Samsung Galaxy S6',
'real_mobile': 'true',
'browserstack.local': 'false',
'resolution': '800x600',
'acceptSslCerts': true,
'deviceOrientation': 'landscape'
},
'iPhone6': {
'os_version': '11.2',
'device': 'iPhone 6',
'real_mobile': 'true',
'browserstack.local': 'false',
'browserName': 'Chrome',
'browser_version': '68.0',
'acceptSslCerts': true,
'resolution': '800x600',
},
'iPad4': {
'os_version': '9.1',
'device': 'iPad Mini 4',
'browserstack.local': 'false',
'acceptSslCerts': true
},
'ie': {
'os': 'Windows',
'os_version': '10',
'browserName': 'IE',
'browser_version': '11.0',
'resolution': '1024x768',
'acceptSslCerts': true,
}
};
module.exports = function get(browsers) {
if (!!browsers) {
let multiCapabilities = [];
browsers = browsers.split('=')[1].trim();
browsers.split(',').forEach(function (browser) {
browser = browser.trim();
if (capabilitiesList.keys().includes(browser)) {
multiCapabilities.push(capabilitiesList[browser]);
}
});
return multiCapabilities.length === 0 ? undefined : multiCapabilities;
}
};
2)更改量角器conf.js
以接受来自cmd行的浏览器,然后调用get()
函数以返回功能列表。
let capabilities = require('./capabilities.js');
let browsers = process.argv.find((it) => {
return it.includes('--browsers=');
});
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['./test.js'],
capabilities: {
browserName: 'chrome'
},
multiCapabilities: capabilities.get(browsers),
jasmineNodeOpts: {
// If true, print colors to the terminal.
showColors: true,
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 3600000,
// Function called to print jasmine results.
print: function() {},
}
};
3)在cmd行中指定浏览器
protractor conf.js --browsers=ie // for running only one browser
protractor conf.js --browsers=ie,iPad4 // for running multiple browsers
protractor conf.js // will run on chrome browser