puppeteer/website/versioned_docs/version-10.1.0/puppeteer.page.waitfor.md
2021-08-10 11:09:48 +01:00

2.0 KiB

Home > puppeteer > Page > waitFor

Page.waitFor() method

Warning: This API is now obsolete.

Don't use this method directly. Instead use the more explicit methods available: Page.waitForSelector(), Page.waitForXPath(), Page.waitForFunction() or Page.waitForTimeout().

Signature:

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[] arguments to pass to pageFunction.

Returns:

Promise<JSHandle>

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() or Page.waitForXPath().

If the first argument is a function this method is a shortcut for Page.waitForFunction().

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.