3

以下脚本有效,但是,当一个测试发生错误时,它似乎也会导致所有其他测试失败。您是如何做到的,以便它们彼此独立运行?

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')
    ...

});
4

1 回答 1

1

在您的测试中添加 Try-Catch 应该可以解决这个问题:

try {
    var webdriverio = require('webdriverio');
    var client = webdriverio
    .remote(options)
    .init()
    .url('http://google.com')
    ...
}
catch(err) {
    //log the error
} 
于 2015-07-03T07:59:44.853 回答