mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
43 lines
2.1 KiB
Markdown
43 lines
2.1 KiB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
[Home](./index.md) > [puppeteer](./puppeteer.md) > [Page](./puppeteer.page.md) > [waitFor](./puppeteer.page.waitfor.md)
|
|
|
|
## Page.waitFor() method
|
|
|
|
> Warning: This API is now obsolete.
|
|
>
|
|
> Don't use this method directly. Instead use the more explicit methods available: [Page.waitForSelector()](./puppeteer.page.waitforselector.md)<!-- -->, [Page.waitForXPath()](./puppeteer.page.waitforxpath.md)<!-- -->, [Page.waitForFunction()](./puppeteer.page.waitforfunction.md) or [Page.waitForTimeout()](./puppeteer.page.waitfortimeout.md)<!-- -->.
|
|
>
|
|
|
|
<b>Signature:</b>
|
|
|
|
```typescript
|
|
waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {
|
|
visible?: boolean;
|
|
hidden?: boolean;
|
|
timeout?: number;
|
|
polling?: string | number;
|
|
}, ...args: SerializableOrJSHandle[]): Promise<JSHandle>;
|
|
```
|
|
|
|
## Parameters
|
|
|
|
| Parameter | Type | Description |
|
|
| --- | --- | --- |
|
|
| selectorOrFunctionOrTimeout | string \| number \| Function | a selector, predicate or timeout to wait for. |
|
|
| options | { visible?: boolean; hidden?: boolean; timeout?: number; polling?: string \| number; } | optional waiting parameters. |
|
|
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | arguments to pass to <code>pageFunction</code>. |
|
|
|
|
<b>Returns:</b>
|
|
|
|
Promise<[JSHandle](./puppeteer.jshandle.md)<!-- -->>
|
|
|
|
## Remarks
|
|
|
|
This method behaves differently depending on the first parameter. If it's a `string`<!-- -->, it will be treated as a `selector` or `xpath` (if the string starts with `//`<!-- -->). This method then is a shortcut for [Page.waitForSelector()](./puppeteer.page.waitforselector.md) or [Page.waitForXPath()](./puppeteer.page.waitforxpath.md)<!-- -->.
|
|
|
|
If the first argument is a function this method is a shortcut for [Page.waitForFunction()](./puppeteer.page.waitforfunction.md)<!-- -->.
|
|
|
|
If the first argument is a `number`<!-- -->, it's treated as a timeout in milliseconds and the method returns a promise which resolves after the timeout.
|
|
|