To cancel a file chooser in Puppeteer, start waiting for it before triggering the upload control, then call await fileChooser.cancel(). This closes the chooser without selecting a file.
Cancel the chooser with FileChooser.cancel()
Use page.waitForFileChooser() and the action that opens the chooser together in Promise.all(). The waiter must be registered before the action; it will not attach to a chooser that is already open.
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('#upload-file-button'),
]);
await fileChooser.cancel();
Replace #upload-file-button with a selector for the page control that opens the file picker. This example assumes page is an existing Puppeteer page. The returned FileChooser represents the intercepted chooser, and cancel() returns a promise, so await it.
Why the order matters
Registering waitForFileChooser() before the click prevents a race in which the chooser opens before Puppeteer begins waiting. The combined Promise.all() pattern starts the waiter and triggers the action as one operation, following Puppeteer’s documented usage.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
Every intercepted chooser should be resolved: call cancel() when you do not want to choose a file, or accept(paths) when the test should supply files. Leaving a chooser unresolved can prevent subsequent chooser requests from appearing.
Canceling versus accepting a file
- Cancel:
await fileChooser.cancel()closes the chooser without selecting files. - Accept:
await fileChooser.accept(paths)supplies the file paths your test intends to upload.
Choose one outcome for each intercepted chooser; do not leave it open if later steps may trigger another chooser.
Limits and common failures
- The chooser opened before the waiter:
waitForFileChooser()does not return an already-active chooser. Set up the wait before clicking or otherwise triggering the upload control. window.showOpenFilePicker()is not intercepted: Puppeteer’s currentwaitForFileChooser()documentation says this DOM picker API is unsupported by the method. The pattern above applies to file chooser events Puppeteer does intercept, not that API.- A later chooser does not appear: Check whether an earlier intercepted chooser was left unresolved. Accept or cancel each one before relying on subsequent chooser requests.
- You expected to see a native picker window: When Puppeteer handles the chooser with this method, the native picker UI does not appear to the user, including in headful mode.
Do not confuse file choosers with JavaScript dialogs
FileChooser.cancel() closes an intercepted file picker. Puppeteer’s Dialog.dismiss() belongs to its separate JavaScript Dialog abstraction; it is not the method for canceling a file chooser.
Version note
The current FileChooser.cancel() reference gives the asynchronous signature cancel(): Promise<void>, so await it. Puppeteer’s changelog records that the method became synchronous in version 9.0.0, released April 21, 2021. If maintaining older automation or interpreting old examples, check the installed Puppeteer version rather than assuming an old signature still applies.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
Or skip the browser setup
If you need an image or PDF of a website rather than browser-side upload automation, ScreenshotNeo can capture it with one GET request. Its API removes cookie banners, popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed; and its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.
See the ScreenshotNeo API documentation. Example cURL request:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Sign up for 1,000 free screenshots a month with no card.
Quick Recap
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.

