About

Puppeteer Guide is an independent collection of practical guides, inline code examples and answers to common Puppeteer errors.


Puppeteer Guide helps you build browser automation with JavaScript and Node.js. It is an independent resource, not the official Puppeteer documentation. You will find practical guides, examples you can copy into your own project, and an error reference for when something goes wrong.

Where to start

New to Puppeteer? Start with how to use Puppeteer. It walks through installation, creating a browser and page, reading content, and closing the browser when you are done. If setup fails, the installation guide covers browser downloads, paths and permissions.

The guides cover specific tasks:

Using the examples

Examples live inside each article. Complete scripts include imports and browser cleanup; shorter snippets assume a page or browser has already been created. Read the surrounding explanation and replace selectors, paths and URLs with values for your own task.

For example, this snippet waits for a heading and reads its text from an existing page:

const heading = await page.waitForSelector("h1", {
    timeout: 5000,
});

if (!heading) {
    throw new Error("Required heading absent");
}

try {
    const text = await heading.evaluate(
        (element) => element.textContent,
    );

    console.log(text);
} finally {
    await heading.dispose();
}

A heading may not prove that your application has finished its work. Choose the element or state that represents the result you actually need.

When something goes wrong

Look up the full message in All Puppeteer errors, or follow Diagnose and fix Puppeteer errors to work out where the failure happened. The goal is to fix the cause, not hide it behind a catch-and-retry loop.

Only automate sites and data you are authorized to access. Keep the browser sandbox enabled, respect privacy and rate limits, and check the result before retrying actions that submit, send or delete something.