mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
42 lines
1.3 KiB
Markdown
42 lines
1.3 KiB
Markdown
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||
|
|
||
|
[Home](./index.md) > [puppeteer](./puppeteer.md) > [Page](./puppeteer.page.md) > [waitForFileChooser](./puppeteer.page.waitforfilechooser.md)
|
||
|
|
||
|
## 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.
|
||
|
|
||
|
```js
|
||
|
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.
|
||
|
|
||
|
<b>Signature:</b>
|
||
|
|
||
|
```typescript
|
||
|
waitForFileChooser(options?: WaitTimeoutOptions): Promise<FileChooser>;
|
||
|
```
|
||
|
|
||
|
## Parameters
|
||
|
|
||
|
| Parameter | Type | Description |
|
||
|
| --- | --- | --- |
|
||
|
| options | [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) | Optional waiting parameters |
|
||
|
|
||
|
<b>Returns:</b>
|
||
|
|
||
|
Promise<[FileChooser](./puppeteer.filechooser.md)>
|
||
|
|
||
|
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.
|
||
|
|