puppeteer/new-docs/puppeteer.frame.waitfor.md
Jack Franklin f04bec5a15
chore: update eslint & eslint plugins (#6487)
Updates ESLint, the TypeScript ESLint plugins, and updates code where
the rules have changed.
2020-10-12 10:30:35 +01:00

2.0 KiB

Home > puppeteer > Frame > waitFor

Frame.waitFor() method

Warning: This API is now obsolete.

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

Signature:

waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: Record<string, unknown>, ...args: SerializableOrJSHandle[]): Promise<JSHandle | null>;

Parameters

Parameter Type Description
selectorOrFunctionOrTimeout string | number | Function a selector, predicate or timeout to wait for.
options Record<string, unknown> optional waiting parameters.
args SerializableOrJSHandle[] arguments to pass to pageFunction.

Returns:

Promise<JSHandle | null>

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

If the first argument is a function this method is a shortcut for Frame.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.