screenshot(filename [, options, callback])
Takes a screenshot of the current page.
— filename (String)
(String)
Where to save the image on disk. The format is defined by the file extension, it defaults to JPEG. 'image.jpg'
will create a JPEG image in the current working directory. There are two supported formats: png
and jpg
.
— options (PlainObject)
(PlainObject)
Screenshot configuration (optional).
{
quality: 80, // used only when generating a JPEG image (75 by default)
fullPage: true // this is true by default, can only be disabled with the Chrome driver
}
— callback (Function(err))
(Function(err))
Function called when finished (optional).
err (String)
:null
or a description of what went wrong if something went wrongfilename (String)
: path of the image file on disk (if the screenshot was successful)
try {
const path = await tab.screenshot("image.jpg")
console.log("Screenshot saved at", path)
// Your screenshot is available at this path
} catch (err) {
console.log("Could not take a screenshot:", err)
}
const path = "./image.jpg"
tab.screenshot(path)
.then(() => {
console.log("Screenshot saved at", path)
// Your screenshot is available at this path
})
.catch((err) => {
console.log("Could not take a screenshot:", err)
})
var path = "./image.jpg"
tab.screenshot(path, function(err) {
if (err) {
console.log("Could not take a screenshot:", err)
}
else {
console.log("Screenshot saved at", path)
// Your screenshot is available at this path
}
})