【问题标题】:How do you run webdriver io tests for different browsers in a loop?你如何循环运行不同浏览器的 webdriver io 测试?
【发布时间】:2015-07-02 23:34:12
【问题描述】:

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

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

});

【问题讨论】:

标签: node.js selenium webdriver-io


【解决方案1】:

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

try {
    var webdriverio = require('webdriverio');
    var client = webdriverio
    .remote(options)
    .init()
    .url('http://google.com')
    ...
}
catch(err) {
    //log the error
} 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-23
    • 2012-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-23
    相关资源
    最近更新 更多