I'm using Axios and alasql npm packages with nightwatchjs to test a list of URLs (from a spreadsheet).
The test works as I'd hoped, in that the webpage is loaded, and the subsequent HTML checked to ensure that Bauer.Golf.CourseCountry.Search is not present within the page HTML.
My code is below;
var alasql = require('alasql');
var axios = require('axios');
module.exports = {
'@tags': ['priorityDesktopTest','priorityMobileTest','stagingDesktopTest','stagingMobileTest'],
'Sitemap test for TG pages': async (browser) => {
var result = await alasql.promise('select URL from xlsx("./testUrls.xlsx",{sheetid:"Sheet2"})');
var xcelData = result.map(item => {
return item.URL;
});
async function siteMapUrlsTestArr(item) {
axios.get(browser.launch_url + item)
.then(html => {
const pageInfo = html.data;
browser.verify.equal((pageInfo.includes("Bauer.Golf.CourseCountry.Search")), false);
});
}
for (let index = 0; index < 2500; index++) {
var xmlTestUrl = xcelData[Math.floor(Math.random()*xcelData.length)];
await siteMapUrlsTestArr(xmlTestUrl);
}
},
};
But at the moment, if there's an error in one of the URLs, then the output only displays;
✖ NightwatchAssertError Failed [equal]: (true == false) - expected "false" but got: "true" (2ms)
Error location:
/Users/darrenharley/Documents/Git/uk-content-todaysgolfer/Tests/Functional/priorityTests/QA-633-sitemap.js:21
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
19 | .then(html => {
20 | const pageInfo = html.data;
21 | browser.verify.equal((pageInfo.includes("Bauer.Golf.CourseCountry.Search")), false);
22 | });
23 | }
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
But what I'd like to do is also specifically display the failing URL, so I can debug this, rather than the generic output I currently get.
However, I'll be testing 2500 URLs so only want the failing URL displayed.
Any help would be greatly appreciated. Thanks.