我想使用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的正确方法是什么?
你应该这样写:
urls.forEach(function(url){
// your code there
});