以下脚本有效,但是,如果在一次测试中发生错误,则会导致所有其他测试失败。你是如何做到的,以便彼此独立运行?
var combos = [
['Windows 7', 'firefox'],
['Windows 7', 'chrome'],
['Windows 7', 'iexplore'],
['Windows 7', 'opera'],
['Windows 8', 'firefox'],
['Windows 8', 'chrome'],
['Windows 8', 'iexplore'],
['Windows 8', 'opera']
];
combos.forEach(function(currentValue) {
var options = {
desiredCapabilities: {
browserName: currentValue[1],
platform: currentValue[0]
},
host: 'ondemand.saucelabs.com',
port: 80,
user: [redacted],
key: [redacted],
logLevel: "verbose"
};
var webdriverio = require('webdriverio');
var client = webdriverio
.remote(options)
.init()
.url('http://google.com')
...
});
答案 0 :(得分:1)
在测试中添加Try-Catch应解决此问题:
try {
var webdriverio = require('webdriverio');
var client = webdriverio
.remote(options)
.init()
.url('http://google.com')
...
}
catch(err) {
//log the error
}