Taking a screenshot using Puppeteer is a simple process. Once you have created the Puppeteer page
object, you can use the screenshot()
method to save a screenshot of the page.
Here is an example of how to save a screenshot as screenshot.jpg
:
const page = await browser.newPage();
await page.screenshot({
path: 'screenshot.jpg'
});
To capture the entire page, you can add the fullPage
option to the screenshot()
method:
await page.screenshot({
path: 'screenshot.jpg',
fullPage: true
});
For a more comprehensive understanding of Puppeteer, you may refer to my full Puppeteer tutorial.