Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Go to Latest
method Page.prototype.waitForFileChooser
import { Page } from "https://deno.land/x/puppeteer@14.1.1/vendor/puppeteer-core/puppeteer/common/Page.js";

This method is typically coupled with an action that triggers file choosing. The following example clicks a button that issues a file chooser and then responds with /tmp/myfile.pdf as if a user has selected this file.

const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('#upload-file-button'),
// some button that triggers file selection
]);
await fileChooser.accept(['/tmp/myfile.pdf']);

NOTE: This must be called before the file chooser is launched. It will not return a currently active file chooser.

Parameters

optional
options: WaitTimeoutOptions
  • Optional waiting parameters

Returns

Promise<FileChooser>

Resolves after a page requests a file picker.