I am trying to write an automated test script which simply takes screenshots of a web page every x seconds until killed. This is kind of a "catch all" for test scenarios that are not common enough to want to automate fully. Someone can manually go back into the screenshots and see how long the web UI took to accomplish some task (these will be minutes or hours in length typically).
This is my code:
it('should monitor a page taking a screenshot every once in a while', function() {
browser.get("www.google.com");
while (true) {
//filename logic is here
var date = new Date().toISOString();
var fileName = location + date + ".png";
console.log('filename is: ' + fileName);
//screenshot saving logic is here
browser.takeScreenshot()
.then(function(png) {
console.log('taking screenshot');
console.log(png);
writeScreenShot(png, fileName);
})
.catch(function(error) {
console.error(error);
});
//delay logic is here
}
});
Everything inside the "browser.takeScreenshot()" promise resolution never gets called, and I'm not sure why. I followed the tutorial here: