假设我已经自动化了25个测试,并在chrome,firefox,IE,Edge和Safari等多种浏览器中执行。所有测试(25)在Chrome上都能正常执行。在Firefox中,由于不支持量角器API,因此只有20个测试运行良好。同样,IE只能执行23个测试。
我只想跳过不支持特定测试的浏览器的测试?有什么办法吗?
答案 0 :(得分:0)
您可以为每个具有特定protracotr.conf
的浏览器创建suites
文件,并在其中指定应该运行哪些测试。并一次执行所有protractor.conf
个文件。
//protractor.chrome.conf
export let config: Config = {
...
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 1
},
SELENIUM_PROMISE_MANAGER: false,
specs: [
'../test/chrome/**/*.js'
]
};
和
//protractor.ie.conf
export let config: Config = {
...
capabilities: {
browserName: 'internet explorer',
shardTestFiles: true,
maxInstances: 1
},
SELENIUM_PROMISE_MANAGER: false,
specs: [
'../test/ie/**/*.js'
]
};
在您的package.json
中:
{
...
"scripts": {
"test:all": "npm run test:chrome && test:ie",
"test:chrome": "protractor ./config/protractor.chrome.conf.js",
"test:ie": "protractor ./config/protractor.ie.conf.js",
...
},
...
}
答案 1 :(得分:0)
使用jasmine2,您可以使用正则表达式过滤测试。也许您可以在测试中添加@ chrome,@ ie之类的东西,然后仅通过传递grep标志来运行那些测试:
it('should do stuff @ie @chrome', function() {
...
});
然后通过grep标志运行量角器:
protractor conf.js --grep='@ie'