Reputation: 2073
Is it possible to read a file in Nightwatch where URLs are saved and execute the same test for each of them?
Upvotes: 2
Views: 962
Reputation: 2073
I figured it out yesterday, so I would like to share:
module.exports = {
'Warm-Up Process': function (browser) {
function urls(url) {
return browser.launchUrl + url;
}
var json = require('./myexport.json');
json.forEach(function(callurl){
browser.url(urls(callurl));
browser.waitForElementVisible('body', 10000);
});
browser.end();
}
};
Upvotes: 1
Reputation: 1676
Remember nightwatch.js is still javascript, you can read the file of urls (e.g. csv) then iterate through the array of url list.
var urls={url1,url2,url3.....url100}
urls.foreach(url){
browser.url(url);
.whatever();
}
browser.end();//end only after all urls are finished.
Upvotes: 3
Reputation: 1955
Yes. Is it possible to read a file in Nightwatch where URLs are saved and execute the same test for each of them in a for loop. You'll want to, if possible, ingest it as JSON.
Upvotes: 0