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

evaluate

Evaluates JavaScript in the frame context.
Returns the return value of pageFunction. If the function returns a Promise, evaluate will wait for that Promise to resolve and return its value.
Upstream docs
pageFunction
string
required
arg
unknown
result
unknown
Return value
await frame.evaluate('...');

evaluateHandle

Evaluates a function in the frame’s context and returns a handle to the result.
Returns a JSHandle for the in-page object. Unlike evaluate, this does not return the value of the function, but a handle pointing to the value.
Upstream docs
pageFunction
string
required
arg
unknown
result
SerializedHandle
Return value
await frame.evaluateHandle('...');

$eval

Finds an element matching selector and passes it to pageFunction.
Returns the value of pageFunction. Throws if selector matches no elements. Discouraged: use locator-based locator.evaluate() instead.
Upstream docs
selector
string
required
pageFunction
string
required
arg
unknown
result
unknown
Return value
await frame.$eval('...', '...');

$$eval

Finds all elements matching selector and passes them to pageFunction.
Returns the value of pageFunction. Discouraged: use locator-based locator.evaluateAll() instead.
Upstream docs
selector
string
required
pageFunction
string
required
arg
unknown
result
unknown
Return value
await frame.$$eval('...', '...');