Skip to main content
Frame waiting methods for the Playwright driver.

waitForSelector

Returns when element specified by selector satisfies state option.
Returns null if waiting for hidden or detached. Returns the ElementHandle matching the selector in visible/attached states. Discouraged: use locator-based locator.waitFor() instead.
Upstream docs
selector
string
required
options
PlaywrightWaitForSelectorOptions
result
SerializedHandle | null
Return value
await frame.waitForSelector('...');

waitForTimeout

Waits for the given timeout in milliseconds.
Note: This should never be used in production. Tests that wait for time are inherently flaky. Use Locator actions and web assertions that wait automatically.
Upstream docs
timeout
number
required
await frame.waitForTimeout(0);

waitForFunction

Returns when the pageFunction returns a truthy value.
It resolves to a JSHandle of the truthy value. The function is called periodically. You can pass a polling interval.
Upstream docs
pageFunction
string
required
arg
unknown
options
{ timeout?: number; polling?: number | "raf" }
result
SerializedHandle
Return value
await frame.waitForFunction('...');