Patrick
Patrick

Reputation: 695

Iterating Nightwatch task over array of URLs

I want to use Nightwatch.js to iterate over a collection of URLs in a system. My test is:

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();
}

};

The urls are just for testing. I would expect the test to iterate over the urls, but an error is thrown:

urls.forEach(url){

unexpected token { on the line above. What would be the correct way to iterate over a collection of URLs?

Upvotes: 0

Views: 315

Answers (1)

brz
brz

Reputation: 115

You should write that:

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

Upvotes: 1

Related Questions