以下脚本有效,但是,似乎当一个测试中出现错误时,它会导致所有其他测试也失败。如何使它们彼此独立运行?
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')
...
});
最佳答案
将 Try-Catch 添加到您的测试应该可以解决这个问题:
try {
var webdriverio = require('webdriverio');
var client = webdriverio
.remote(options)
.init()
.url('http://google.com')
...
}
catch(err) {
//log the error
}
关于node.js - 你如何在循环中为不同的浏览器运行 webdriver io 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31196290/