mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
docs: clarify Page.waitForFunction()
docs to mention that it will w… (#11592)
This commit is contained in:
parent
4468ab21ed
commit
0651d2c68e
@ -155,7 +155,7 @@ page.off('request', logRequest);
|
||||
| [waitForDevicePrompt(options)](./puppeteer.page.waitfordeviceprompt.md) | | <p>This method is typically coupled with an action that triggers a device request from an api such as WebBluetooth.</p><p>:::caution</p><p>This must be called before the device request is made. It will not return a currently active device prompt.</p><p>:::</p> |
|
||||
| [waitForFileChooser(options)](./puppeteer.page.waitforfilechooser.md) | | <p>This method is typically coupled with an action that triggers file choosing.</p><p>:::caution</p><p>This must be called before the file chooser is launched. It will not return a currently active file chooser.</p><p>:::</p> |
|
||||
| [waitForFrame(urlOrPredicate, options)](./puppeteer.page.waitforframe.md) | | Waits for a frame matching the given conditions to appear. |
|
||||
| [waitForFunction(pageFunction, options, args)](./puppeteer.page.waitforfunction.md) | | Waits for a function to finish evaluating in the page's context. |
|
||||
| [waitForFunction(pageFunction, options, args)](./puppeteer.page.waitforfunction.md) | | Waits for the provided function, <code>pageFunction</code>, to return a truthy value when evaluated in the page's context. |
|
||||
| [waitForNavigation(options)](./puppeteer.page.waitfornavigation.md) | | Waits for the page to navigate to a new URL or to reload. It is useful when you run code that will indirectly cause the page to navigate. |
|
||||
| [waitForNetworkIdle(options)](./puppeteer.page.waitfornetworkidle.md) | | |
|
||||
| [waitForRequest(urlOrPredicate, options)](./puppeteer.page.waitforrequest.md) | | |
|
||||
|
@ -4,7 +4,7 @@ sidebar_label: Page.waitForFunction
|
||||
|
||||
# Page.waitForFunction() method
|
||||
|
||||
Waits for a function to finish evaluating in the page's context.
|
||||
Waits for the provided function, `pageFunction`, to return a truthy value when evaluated in the page's context.
|
||||
|
||||
#### Signature:
|
||||
|
||||
@ -23,11 +23,11 @@ class Page {
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| ------------ | ------------------------------------------------------------------------- | ------------------------------------------------------ |
|
||||
| pageFunction | Func \| string | Function to be evaluated in browser context |
|
||||
| options | [FrameWaitForFunctionOptions](./puppeteer.framewaitforfunctionoptions.md) | _(Optional)_ Options for configuring waiting behavior. |
|
||||
| args | Params | |
|
||||
| Parameter | Type | Description |
|
||||
| ------------ | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
||||
| pageFunction | Func \| string | Function to be evaluated in browser context until it returns a truthy value. |
|
||||
| options | [FrameWaitForFunctionOptions](./puppeteer.framewaitforfunctionoptions.md) | _(Optional)_ Options for configuring waiting behavior. |
|
||||
| args | Params | |
|
||||
|
||||
**Returns:**
|
||||
|
||||
@ -35,7 +35,7 @@ Promise<[HandleFor](./puppeteer.handlefor.md)<Awaited<ReturnType<Fun
|
||||
|
||||
## Example 1
|
||||
|
||||
The [Page.waitForFunction()](./puppeteer.page.waitforfunction.md) can be used to observe viewport size change:
|
||||
[Page.waitForFunction()](./puppeteer.page.waitforfunction.md) can be used to observe a viewport size change:
|
||||
|
||||
```ts
|
||||
import puppeteer from 'puppeteer';
|
||||
@ -51,7 +51,7 @@ import puppeteer from 'puppeteer';
|
||||
|
||||
## Example 2
|
||||
|
||||
To pass arguments from node.js to the predicate of [Page.waitForFunction()](./puppeteer.page.waitforfunction.md) function:
|
||||
Arguments can be passed from Node.js to `pageFunction`:
|
||||
|
||||
```ts
|
||||
const selector = '.foo';
|
||||
@ -64,7 +64,7 @@ await page.waitForFunction(
|
||||
|
||||
## Example 3
|
||||
|
||||
The predicate of [Page.waitForFunction()](./puppeteer.page.waitforfunction.md) can be asynchronous too:
|
||||
The provided `pageFunction` can be asynchronous:
|
||||
|
||||
```ts
|
||||
const username = 'github-username';
|
||||
|
@ -2901,10 +2901,11 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for a function to finish evaluating in the page's context.
|
||||
* Waits for the provided function, `pageFunction`, to return a truthy value when
|
||||
* evaluated in the page's context.
|
||||
*
|
||||
* @example
|
||||
* The {@link Page.waitForFunction} can be used to observe viewport size change:
|
||||
* {@link Page.waitForFunction} can be used to observe a viewport size change:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
@ -2919,8 +2920,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* To pass arguments from node.js to the predicate of
|
||||
* {@link Page.waitForFunction} function:
|
||||
* Arguments can be passed from Node.js to `pageFunction`:
|
||||
*
|
||||
* ```ts
|
||||
* const selector = '.foo';
|
||||
@ -2932,7 +2932,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* The predicate of {@link Page.waitForFunction} can be asynchronous too:
|
||||
* The provided `pageFunction` can be asynchronous:
|
||||
*
|
||||
* ```ts
|
||||
* const username = 'github-username';
|
||||
@ -2954,7 +2954,8 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param pageFunction - Function to be evaluated in browser context
|
||||
* @param pageFunction - Function to be evaluated in browser context until it returns a
|
||||
* truthy value.
|
||||
* @param options - Options for configuring waiting behavior.
|
||||
*/
|
||||
waitForFunction<
|
||||
|
Loading…
Reference in New Issue
Block a user