Reputation: 22560
I am trying to generate a screenshot with nightwatch js , it saves a file to my location but the size is 1kb and when I try to open this there is no image. The config file is the one I got from https://www.npmjs.com/package/learn-nightwatch. What could be the culprit?
Upvotes: 0
Views: 2427
Reputation: 29
As it stands this is how you can set up automatic screenshots in nightwatch.conf.js
"screenshots": {
"enabled": true,
"path": "./tests_output/screenshots", // location to save
"on_failure": true,
"on_error": true
}
Upvotes: 1
Reputation: 7871
Before you launch the screenshot, you need to be sure that the page is "ready". If you already checked that, please make sure that you added an image extension to the file name.
I'm sharing a working example:
module.exports = {
"Do a screenshot task" : function (browser) {
browser
.url("http://example.com")
.waitForElementPresent('body', 1000, 'Page loaded')
.resizeWindow(900, 3000)
.saveScreenshot('/home/yourName/path/imageName.png')
.end();
}
};
Hope it helps you.
Upvotes: 1