I'm attempting to build an automated test with Nightwatch.js in order to verify that software download links are working correctly. I don't want to download the files, as they are quite large, I just want to verify that the corresponding link is returning a 200 HTTP response to make sure the links are pointing to the proper place.
Any idea for ways to test links to downloadable files with Nightwatch.js?
Here's what I currently have:
/**
* Test Software Downloads
*
* Verify that software downloads are working
*/
module.exports = {
"Download redirect links": function (browser) {
// download links
var downloadLinks = {
"software-download-latest-mac": "http://downloads.company.com/mac/latest/",
"software-download-latest-linux": "http://downloads.company.com/linux/latest/",
"software-download-latest-win32": "http://downloads.company.com/windows/32/latest/",
"software-download-latest-win64": "http://downloads.company.com/windows/64/latest/"
};
// loop through download links
for (var key in downloadLinks) {
if (downloadLinks.hasOwnProperty(key)) {
// test each link's status
browser
.url(downloadLinks[key]);
}
}
// end testing
browser.end();
}
};
http
module and make a "HEAD" requesttest.js
var http = require("http");
module.exports = {
"Is file avaliable" : function (client) {
var request = http.request({
host: "www.google.com",
port: 80,
path: "/images/srpr/logo11w.png",
method: "HEAD"
}, function (response) {
client
.assert.equal(response.headers["content-length"], 14022, 'Same file size');
client.end();
}).on("error", function (err) {
console.log(err);
client.end();
}).end();
}
};
References
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With