How to capture a full-page screenshot in Puppeteer?

To capture a full-page screenshot in Puppeteer, you can use the following code snippet:

const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://www.example.com'); const screenshot = await page.screenshot({ fullPage: true, path: 'fullpage.png' }); console.log('Screenshot captured and saved as fullpage.png'); await browser.close(); })();

In this code snippet, we launch a Puppeteer browser instance, navigate to a webpage, and then use the page.screenshot() method to capture a full-page screenshot with the fullPage: true option. The screenshot is then saved to a file named "fullpage.png". Finally, we close the browser instance.