Puppeteer
Headless Chrome/Chromium automation for scraping, testing and screenshot generation.
3. Used by agents' projects
Dependency in 86 public GitHub projects set up for AI coding agents that we scanned (1.4%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Puppeteer does
Puppeteer is the Chrome Browser Automation team's own JavaScript library for driving Chrome or Firefox, and each release is pinned to a specific browser build so protocol changes do not break your scripts.
Puppeteer popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Puppeteer is used
- Puppeteer is a dependency in 86 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.8% of the 4,867 JavaScript/TypeScript ones), #2 of 141 in scraping, browsers and parsing.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 252; those are left out of every share on this page.
- The most used alternative in our scan is Playwright Core (80 projects).
- Projects that use it most often also use dotenv (50.0%), Axios (38.4%), Playwright (JavaScript) (44.2%).
- It is more common in projects set up for Continue (7.9%) than for GitHub Copilot (1.5%).
By coding agent
Often used with
Puppeteer in practice
Strengths
The FAQ says all input events Puppeteer generates are trusted and fire the accompanying events, such as <code>mousedown</code> and <code>mouseup</code> before a click. Websites can tell trusted events from ones created by Web APIs.
Each Puppeteer release is bundled with a specific Chrome and Firefox release. The docs say this keeps browser changes from unexpectedly breaking Puppeteer. The pinned versions are listed in <code>revisions.ts</code>.
BiDi support is production-ready from v23.0.0. The maintainers write that they will keep supporting Chrome automation over CDP, both for existing scripts and for Chrome-only use cases.
Puppeteer treats any URL change as a navigation. That includes anchor navigations and History API calls, not only full page loads.
Watch out for
The docs say npm, pnpm, Yarn, Bun and Deno block dependency install scripts by default. If the script is blocked, Chrome is not downloaded and you get errors at runtime. The fix is <code>npx puppeteer browsers install</code>, or adding <code>"puppeteer"</code> to <code>"allowScripts"</code>.
The FAQ says bindings for other languages and tooling to orchestrate automation at scale are beyond Puppeteer's scope. It names Selenium Grid as an example of the latter.
API support over WebDriver BiDi is not identical to CDP. The FAQ points to a separate guide for the "subtle differences."
Search a page and read a result title
import puppeteer from 'puppeteer';
// Or import puppeteer from 'puppeteer-core';
// Launch the browser and open a new blank page.
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Navigate the page to a URL.
await page.goto('https://developer.chrome.com/');
// Set the screen size.
await page.setViewport({width: 1080, height: 1024});
// Open the search menu using the keyboard.
await page.keyboard.press('/');
// Type into search box using accessible input name.
await page.locator('::-p-aria(Search)').fill('automate beyond recorder');
// Wait and click on first result.
await page.locator('.devsite-result-item-link').click();
// Locate the full title with a unique string.
const textSelector = await page
.locator('::-p-text(Customize and automate)')
.waitHandle();
const fullTitle = await textSelector?.evaluate(el => el.textContent);
// Print the full title.
console.log('The title of this blog post is "%s".', fullTitle);
await browser.close();More about Puppeteer
Head to head
- Puppeteer vs Playwright Core used together in 0 projects
Packages around it
- dotenv: Loads .env variables
- @playwright/test: Playwright test runner
- axios: HTTP client
- jsdom: DOM in Node.js
- jest: Test runner
- zod: Schema validation
More in Scraping, browsers and parsing
Alternatives
Puppeteer This page
Headless browser automation library for cross-browser testing and web scraping.
Browser agent SDK for building web automation agents.
Get started
Install it.
npm install puppeteerRules for your agent
## Puppeteer
- Install `puppeteer` when you want it to download a compatible Chrome. Install `puppeteer-core` when the project supplies its own browser.
- If the package manager blocks install scripts, run `npx puppeteer browsers install` after install, or add `"puppeteer"` to `"allowScripts"` in `package.json`. Otherwise expect runtime errors from a missing browser.
- Do not pair a Puppeteer version with an arbitrary browser version. Each release is bundled with a specific Chrome/Firefox build, listed in `revisions.ts`.
- Prefer `page.locator(...)` with `::-p-aria(...)` or `::-p-text(...)` selectors, as in the README example. Always call `browser.close()` when done.
- Use Puppeteer's input APIs for trusted events. Only use `page.evaluate` with DOM calls like `element.click()` when you deliberately need an untrusted event.
- When targeting Firefox or WebDriver BiDi, check the WebDriver BiDi guide for API differences from CDP.