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.

Listen for the dialog event on the Puppeteer Page that owns the browser interaction. The event gives you a Dialog object; inspect type(), message(), and, for prompts, defaultValue(), then explicitly await dialog.accept() or await dialog.dismiss(). For a prompt that should submit text, pass that text to accept(value).

This event is for JavaScript dialogs such as alert, confirm, prompt, and beforeunload. A modal rendered with ordinary HTML is different: select and operate on its elements with Puppeteer’s locator APIs instead of waiting for a dialog event. See the PageEvent reference, Dialog class reference, and page-interactions guide.

What Puppeteer calls a dialog

Puppeteer surfaces browser-level JavaScript dialogs through the page’s dialog event. The callback receives a Dialog instance representing the currently displayed dialog.

Dialog type Typical source Response method Important detail
alert alert('message') accept() or dismiss() Choose the response that matches the behavior your test is meant to verify.
confirm confirm('Continue?') accept() for proceed, dismiss() for cancel The intended application outcome, not a universal policy, determines the branch.
prompt prompt('Name', 'Guest') accept(value) or dismiss() Use accept(value) when automation must enter text; defaultValue() exposes the displayed default.
beforeunload A page asks whether to leave or close accept() or dismiss() The Puppeteer API exposes the event, but the correct navigation outcome depends on the flow being tested.

The current API references identify these four examples. Documentation pages can carry different version labels, so check the reference that matches the Puppeteer version deployed by your project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Inspect the Dialog object before responding

Use the object’s inspection methods to make the response explicit and auditable.

Method or property What it provides When to use it
type() The dialog type, such as alert, confirm, prompt, or beforeunload. Branch to the response required by the test case.
message() The text displayed by the dialog. Verify that the expected warning or question appeared before continuing.
defaultValue() The prompt’s default text; for non-prompts it is an empty string. Check or preserve a suggested prompt value.
handled Whether the dialog has already been handled. Avoid attempting a second response in complex asynchronous code.

The methods and handled property are documented in the Dialog class reference.

Basic JavaScript pattern: log and dismiss

Register the listener on the relevant page, log the type and message, then resolve every dialog with an awaited response. The listener must choose a response; merely observing the event does not close the dialog.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();

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

await page.goto('https://example.com');
// Perform the action that can show a JavaScript dialog here.

await browser.close();

Puppeteer’s class example likewise logs dialog.message() and awaits dialog.dismiss(). Dismissing is only correct when cancellation is the intended result; change the response for flows that must proceed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Accept alerts, confirms, prompts, and beforeunload dialogs

Accept an alert

An alert has no value to enter. Call accept() and continue with the assertion or action that follows the alert.

page.on('dialog', async dialog => {
  if (dialog.type() === 'alert') {
    console.log('Alert:', dialog.message());
    await dialog.accept();
  }
});

Choose a confirm branch

For a confirmation flow, encode the application outcome you want to test. Accepting represents proceeding; dismissing represents cancelling.

page.on('dialog', async dialog => {
  if (dialog.type() !== 'confirm') return;

  if (dialog.message() === 'Delete this item?') {
    await dialog.accept();
  } else {
    await dialog.dismiss();
  }
});

Matching the message is useful when several confirmations can occur on one page. If the message is not the expected one, dismissing it is a conservative test response; use the behavior your scenario actually requires.

Enter text in a prompt

Pass the text as the optional argument to accept(value). The argument has an effect for prompts; it is ignored for other dialog types.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
page.on('dialog', async dialog => {
  if (dialog.type() !== 'prompt') {
    await dialog.dismiss();
    return;
  }

  console.log('Prompt:', dialog.message());
  console.log('Suggested value:', dialog.defaultValue());
  await dialog.accept('value to submit');
});

If the test should cancel the prompt, call dismiss() instead. The documented signature is accept(promptText?); omitting the argument accepts without replacing the prompt value. See Dialog.accept().

Handle beforeunload deliberately

A beforeunload dialog is delivered through the same event. Decide first whether the scenario is supposed to allow or prevent the navigation or close operation, then call accept() or dismiss() accordingly.

page.on('dialog', async dialog => {
  if (dialog.type() === 'beforeunload') {
    // Select the response required by this navigation test.
    await dialog.dismiss();
    return;
  }

  await dialog.dismiss();
});

The API confirms that beforeunload is surfaced, but browser-version-specific navigation results are not universal. Assert the resulting page state in the flow you are testing rather than assuming that every browser version behaves identically.

A complete type-aware handler

This example records all available inspection data, prevents a second response when the object is already handled, and makes each policy visible in one place.

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.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();

page.on('dialog', async dialog => {
  if (dialog.handled) return;

  const type = dialog.type();
  const message = dialog.message();
  const defaultValue = dialog.defaultValue();

  console.log({ type, message, defaultValue });

  switch (type) {
    case 'prompt':
      if (message === 'Project name?') {
        await dialog.accept('demo-project');
      } else {
        await dialog.dismiss();
      }
      break;
    case 'confirm':
      await dialog.accept();
      break;
    case 'alert':
      await dialog.accept();
      break;
    case 'beforeunload':
      // Pick accept or dismiss for the navigation scenario under test.
      await dialog.dismiss();
      break;
    default:
      await dialog.dismiss();
  }
});

await page.goto('https://example.com');
// Trigger the page action that opens a dialog.

await browser.close();

Use one policy per test scenario. Blindly accepting every type can submit an unintended prompt value or approve a destructive confirmation; blindly dismissing can prevent the path you intended to verify.

JavaScript dialogs versus HTML modals

Visual appearance is not enough to identify a browser dialog. A site can render a custom modal with ordinary HTML, CSS, and JavaScript. Such a modal does not emit Puppeteer’s dialog event.

Symptoms of a DOM modal

  • Your action visibly opens a modal, but the dialog listener never runs.
  • The modal has inspectable buttons, inputs, and containers in the page DOM.
  • The page’s controls can be selected with normal locator APIs.

How to handle it

Inspect the modal’s DOM and interact with it as a page element: locate its input, fill it, and click its confirm or cancel button. Puppeteer’s page-interactions guide recommends locator APIs for ordinary element selection and interaction. Do not wait indefinitely for a JavaScript dialog event when the interface is an in-page component.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Reliable handling practices

Attach the listener before the trigger

Set up the page listener before clicking, navigating, or evaluating code that can open the dialog. This keeps the response policy in place when the event is emitted and avoids a flow that reaches a dialog with no handler.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Always await the response

accept() and dismiss() are asynchronous methods. Await the chosen method so the rest of the test runs after Puppeteer has resolved the dialog.

Keep the policy close to the scenario

Use the message and type to distinguish multiple dialogs. Record the message when diagnosing failures, but do not rely on a message-independent “always accept” rule unless that is genuinely the behavior under test.

Check the deployed API version

The official pages currently show version labels including 25.12.0 for the PageEvent, Page interactions, and Dialog references, while the accept-method page displays 25.11.0. These labels are documentation versions, not a guarantee about the package installed in your project. Use the API reference corresponding to your deployed Puppeteer version.

Troubleshooting dialog automation

Symptom Likely cause Fix
No dialog event arrives. The site uses an HTML modal rather than a JavaScript dialog. Inspect the DOM and handle the modal with locator-based element interactions.
The test stops after the page action. The handler observed the event but never resolved it. Await either dialog.accept() or dialog.dismiss() on every branch.
Prompt text is not entered. The code called accept() without a value, or the dialog is not a prompt. Check type() and call accept('text') for a prompt.
An unexpected action is approved. A global handler accepts every confirmation or alert. Branch on type() and, where appropriate, message(); encode the intended outcome.
A second response throws or behaves inconsistently. Multiple asynchronous paths attempted to handle the same object. Check dialog.handled and centralize the response policy.
Navigation results differ around beforeunload. The desired outcome depends on the browser and navigation scenario. Choose the response deliberately and assert the resulting page state instead of assuming a universal result.

Or skip the browser setup

If your goal is a clean screenshot rather than interactive dialog testing, ScreenshotNeo provides a website screenshot API and MCP server. It can accept cookie or consent banners before capture and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers.

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

One GET request returns an image or PDF. The API also supports full-page captures with lazy images loaded, CSS-selector element captures, dark mode, device presets, custom viewport and retina scale, PDF page settings, custom CSS and JavaScript, clicks before capture, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

cURL

See the ScreenshotNeo documentation for all parameters.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account to get started.

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.

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