puppeteer/website/versioned_docs/version-10.0.0/puppeteer.page.waitforfilechooser.md
TASNEEM KOUSHAR 34ff00e2fe
chore(docs): generate site for v10.0.0
* fix: added parts of website

* fix: removed unnecessary lines

* fix: updated contributing.md

* fix: added parts of sidebar

* fix: added all APIs

* fix: added version 10.0.0

Co-authored-by: Jack Franklin <jacktfranklin@chromium.org>
2021-08-09 09:57:14 +01:00

1.3 KiB

Home > puppeteer > Page > waitForFileChooser

Page.waitForFileChooser() method

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.

Signature:

waitForFileChooser(options?: WaitTimeoutOptions): Promise<FileChooser>;

Parameters

Parameter Type Description
options WaitTimeoutOptions Optional waiting parameters

Returns:

Promise<FileChooser>

Resolves after a page requests a file picker.

Remarks

NOTE: In non-headless Chromium, this method results in the native file picker dialog not showing up for the user.