在URL数组上迭代Nightwatch任务

问题描述 投票:0回答:1

我想使用Nightwatch.js迭代系统中的一组URL。我的测试是:

module.exports = {

'Checking URLs': function (browser) {
    var urls = [
        'https://google.com',
        'https://google.co.th'
    ];
    urls.forEach(url){
        browser
            .url(url)
            .waitForElementVisible('body', 3000)
            .assert.not.elementPresent('.booka-generic-php-error');
    }
    browser.end();
}

};

网址仅供测试。我希望测试迭代url,但会抛出一个错误:

urls.forEach(url){

意外的令牌{在上面的行上。迭代一组URL的正确方法是什么?

nightwatch.js
1个回答
1
投票

你应该这样写:

urls.forEach(function(url){ // your code there });

© www.soinside.com 2019 - 2024. All rights reserved.