Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk6 min

Puppeteer Page Events: Reference and Examples

Learn which Puppeteer Page events to listen for, how to attach and remove handlers, and how to distinguish request failures from HTTP error responses.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Puppeteer’s Page emits events for navigation, network requests, JavaScript diagnostics, dialogs, popups, frames, and workers. Use page.on() for recurring listeners, page.once() for a single event, and page.off() with the original callback to remove a listener. For the authoritative event names and callback payloads, consult the Page API and PageEvent enum; the latter is a next-version reference, so check your installed Puppeteer version before depending on recently added or experimental events.

Attach and remove a Page event listener

Register a listener before the navigation or interaction that may trigger it. This matters especially for one-off events such as a popup: if the event fires before the listener is attached, the listener will not see it.

function logRequest(request) {
  console.log('A request was made:', request.url());
}

page.on('request', logRequest); // recurring listener
page.once('load', () => console.log('Page loaded!')); // first matching event only

// Later, remove the recurring listener using the same function reference.
page.off('request', logRequest);

The Page API documents these EventEmitter-style methods. An inline callback can be used with once(), but to remove a recurring listener later, keep a reference to its function rather than creating a new anonymous function for off().

Which Puppeteer Page events are available?

The PageEvent reference groups events by what is happening in the page. The list below reflects the documented event inventory, including issue, which the reference marks experimental. Event availability and payloads may differ across installed Puppeteer versions; verify them in the API documentation for the version your project uses.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Area Events What they indicate
Lifecycle domcontentloaded, load, close Document lifecycle milestones or page closure.
JavaScript diagnostics console, pageerror, error Console activity, uncaught page exceptions, or a page crash. The console event can include messages produced by page JavaScript, including errors and warnings.
Dialogs and new tabs dialog, popup A JavaScript dialog, or a newly opened tab or window.
Frames frameattached, framenavigated, framedetached A frame joining the page, navigating, or being removed.
Network request, response, requestfinished, requestfailed, requestservedfromcache Request issuance, response arrival, completion, failure, or cache service.
Workers and diagnostics workercreated, workerdestroyed, metrics, issue Worker lifecycle, page metrics, or an experimental issue event.

For each event’s documented callback object and precise meaning, use the PageEvent enum reference. Events do not all pass the same kind of value: examples include HTTPRequest, HTTPResponse, Frame, Dialog, ConsoleMessage, and Page.

Understand request, response, completion, and failure

A request’s events describe a lifecycle, not simply whether the server returned a successful status. In the usual case, Puppeteer emits request, then response when response headers arrive, then requestfinished once the response body has downloaded and the request is complete. If the request fails before completion, Puppeteer emits requestfailed instead of requestfinished.

  • Use request to observe a request being issued.
  • Use response to inspect the response when it arrives, including its status.
  • Use requestfinished to observe a completed exchange.
  • Use requestfailed for a transport-level failure that prevented completion.

A 404 or 503 is still an HTTP response: it normally leads to requestfinished, not requestfailed. Check HTTPResponse.status() to classify HTTP status codes. A redirect completes the original request and issues another request for the redirected URL. The HTTPRequest API describes request lifecycle and failure concepts; HTTPRequest.failure() may return text such as net::ERR_FAILED, but that text is not guaranteed.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Wait for a popup and inspect its page

A popup event supplies a Page for the new tab or window. Attach the one-time listener before clicking or otherwise triggering the opener action, then wait for the action and popup together.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const popupPromise = page.waitForEvent('popup');
await page.click('a[target="_blank"]');
const popup = await popupPromise;
console.log(await popup.url());

This pattern uses the Page event wait helper; if your code uses once() directly instead, likewise attach it before triggering the popup. A popup remains in the opener’s BrowserContext, as described by the BrowserContext API.

Handle dialogs without blocking the page

JavaScript alert, prompt, confirm, and beforeunload dialogs trigger dialog. An unresolved dialog can block page execution, so choose whether to accept or dismiss it in the handler.

page.on('dialog', async dialog => {
  console.log(dialog.type(), dialog.message());
  await dialog.dismiss();
});

Use dialog.accept() when the automation should proceed as if the user accepted; for a prompt, consult the Dialog API for its documented accept options. This example dismisses every dialog, which is suitable only when that is the intended behavior.

Track iframe changes

The parent Page emits frameattached, framenavigated, and framedetached. Their frame payload lets you inspect the frame tree or interact with the relevant child frame.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page.on('framenavigated', frame => {
  console.log('Frame navigated:', frame.url());
});

For frame APIs and frame-tree behavior, see the Frame API.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Observe traffic without changing it

Use the ordinary request, response, and completion events when you only need diagnostics. Do not enable request interception just to log traffic: interception changes loading behavior and requires every intercepted request to be resolved.

When you do need to modify, mock, or abort requests, enable interception and resolve each request with continue(), respond(), or abort(). An unresolved intercepted request stalls unless the browser cache completes it, which can leave navigation or resource loading hanging.

await page.setRequestInterception(true);
page.on('request', async request => {
  try {
    if (request.url().endsWith('.png')) {
      await request.abort();
    } else {
      await request.continue();
    }
  } catch (error) {
    console.error('Could not resolve intercepted request:', error);
  }
});

The setRequestInterception API documents the behavior and basic pattern. In more complex setups, account for other interception handlers and cooperative interception behavior; handle promise failures so an interception action does not fail silently.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common Page event issues

  • A popup or dialog is missed: the triggering action may happen before the listener is attached. Register the listener first, then perform the click or navigation.
  • A 404 does not trigger requestfailed: that is expected for a completed HTTP exchange. Listen for response or inspect the response status instead.
  • Navigation hangs after enabling interception: a request may not have been continued, answered, or aborted. Ensure every request path resolves it, including error paths.
  • A listener keeps firing after its work is done: use once() for a one-time event, or retain the callback and pass that same reference to off().
  • An event is unavailable or behaves differently: check the API reference matching your installed Puppeteer version, especially for events documented only on the /next page or marked experimental.

Or skip the browser setup

If your goal is to obtain a page image or PDF rather than write browser-event automation, ScreenshotNeo provides a one-request screenshot API. See the ScreenshotNeo documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie banners are accepted and removed, along with supported newsletter popups and chat widgets, before capture.
  • Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers identify the page verdict and billing outcome.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up free for 1,000 screenshots a month, with no card required.

Frequently Asked Questions

Does a 404 response trigger Puppeteer’s requestfailed event?

Usually not. A 404 is a completed HTTP response; inspect the response status rather than treating it as a transport-level request failure.

Which object does the popup event provide?

It provides a Puppeteer Page for the newly opened tab or window.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I use the PageEvent list unchanged across Puppeteer versions?

Check the API reference for your installed version. In particular, the cited PageEvent inventory is a next-version reference and marks issue as experimental.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.