Listen for the page’s dialog event, then call dialog.defaultValue() on the dialog object. It returns the prefilled text for a prompt; for an alert, confirm, or beforeunload dialog, Puppeteer returns an empty string.
Read a prompt’s default value
Register a handler for the page’s dialog event. The handler receives a Puppeteer Dialog object, whose defaultValue() method reads the prompt’s initial text.
page.on('dialog', async dialog => {
const initialText = dialog.defaultValue();
console.log(initialText);
await dialog.accept();
});
This assumes page is an existing Puppeteer Page. The handler logs the initial value and accepts the dialog. Calling accept() without an argument submits the prompt’s default value.
Accept the prompt with different text
To submit replacement text instead, pass it to accept():
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
page.on('dialog', async dialog => {
const initialText = dialog.defaultValue();
console.log(initialText);
await dialog.accept('replacement text');
});
The optional argument is used for prompts; it does not change the behavior of other dialog types. A browser prompt’s initial response is the default supplied when the page calls prompt(message, default).
What the method returns for other dialog types
Puppeteer documents four dialog types: alert, beforeunload, confirm, and prompt. Only a prompt has a text value to retrieve. For the other types, defaultValue() returns an empty string.
Troubleshoot dialog handling
- The handler never runs: Attach the
dialoglistener before the action that triggers the dialog. The event is dispatched by the Page when a dialog appears. - The value is empty: Check the dialog’s type. An empty string is the documented result for non-prompt dialogs; it may also be the prompt’s actual default text.
- The prompt closes without replacement text: Pass the desired string to
dialog.accept('replacement text'). Callingaccept()with no argument accepts using the existing prompt default.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server, not a way to read a Puppeteer prompt’s default value. If your separate task is capturing a page rather than inspecting its dialog, one GET request can return an image or PDF. See the ScreenshotNeo API documentation.
Quick Recap
Rank #3
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Before capture, it accepts cookie or consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server offers screenshot and PDF tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo, or sign up for the free plan.
Free tools Windows power users keep installed
One-click scans. No signup required.
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.

