Puppeteer
What Puppeteer is, how it captures screenshots, and how it compares to Playwright for browser automation.
Puppeteer is an open-source Node.js library maintained by the Chrome team at Google. It controls Chrome or Chromium, and also Firefox, through the Chrome DevTools Protocol or WebDriver BiDi. It runs headless by default, so pages load and render without a visible window.
A Puppeteer script launches a browser, opens pages and works with them the way a user would: it navigates, clicks, types and waits for content. The library is commonly used for screenshots, PDF generation, scraping, performance checks and automated tests of Chrome-based web apps.
What Puppeteer can do
- Launch Chrome, Chromium or Firefox, or connect to a running browser.
- Set the viewport, user agent, geolocation and network conditions.
- Click, type, submit forms and wait for selectors or network idle.
- Intercept requests to block ads, images or trackers.
- Save screenshots with
page.screenshot()and PDFs withpage.pdf().
Puppeteer for screenshots
page.screenshot() saves PNG, JPEG or WebP output. The fullPage option captures the entire scrollable document, clip captures a rectangle, and an element handle captures a single element. page.setViewport() sets width, height and deviceScaleFactor, which decides whether output is 1x or 2x resolution.
page.pdf() is different from a screenshot. It uses the browser's print layout and print CSS, so it may paginate the page or hide elements, while page.screenshot() records the rendered screen.
Puppeteer vs Playwright
Puppeteer is a JavaScript library centered on Chrome. Playwright supports Chromium, Firefox and WebKit and offers bindings for JavaScript, Python, Java and .NET, plus a built-in test runner. Puppeteer suits Node.js projects that only need Chrome; Playwright suits teams that need Safari's WebKit engine or another language.
Common mistakes
- Taking the screenshot right after navigation, before fonts and images load.
- Expecting
page.pdf()to look like the screen. - Running many browser instances at once and running out of memory.
- Forgetting to close the browser, which leaves processes running.
Taking the same screenshots again and again?
Temposhot Website Capture loads a URL list in managed local browsers and saves one image per URL, with Viewport or Full page area. See website screenshot automation.
Common questions
Is Puppeteer only for Chrome?
Chrome is the main target. Puppeteer also supports Firefox through WebDriver BiDi.
Can Puppeteer capture retina screenshots?
Yes. Set deviceScaleFactor to 2 in page.setViewport() to get twice the pixel width and height.
Does Puppeteer require coding?
Yes. It is a library used from JavaScript or TypeScript code running on Node.js.
Sources
Related resources
- Website Capture quick start: capture many URLs without code.
- Chrome extension: save one full-page PNG of the current tab.
- Stitch screenshots: join captures into one image in the browser.
Taking the same screenshots again and again?
Temposhot captures a screen, window or area on a timer and exports the set as a PDF, images, ZIP or MP4. The free browser tools fix single images.
Related resources
Related terms
- PlaywrightWhat Playwright is, how it captures cross-browser screenshots, and how it compares to Puppeteer for automation.
- Headless BrowserWhat a headless browser is, how it's used for automated screenshots, and common pitfalls.
- Screenshot APIWhat a screenshot API is, how it works, and when to use one for programmatic capture.
- Browser DevToolsWhat browser DevTools are, how to use them for screenshots and responsive testing, and common features.