Skip to main content
Element Handle evaluation methods for the Playwright driver.

evaluate

Evaluate a function in the context of the element.
The element is passed as the first argument to the function. If the function returns a Promise, it will be awaited.
Upstream docs
pageFunction
string
required
Function or string to evaluate in the page context.
arg
unknown
Argument to pass to the function.
result
unknown
Return value
await element.evaluate('...');

evaluateHandle

Evaluate a function and return a JSHandle to the result.
The element is passed as the first argument. Note: Returns serialized handle reference. Full JSHandle support not yet available.
Upstream docs
pageFunction
string
required
Function or string to evaluate in the page context.
arg
unknown
Argument to pass to the function.
result
unknown
Return value
await element.evaluateHandle('...');

$eval

Evaluate a function on a child element matching the selector.
Throws if no element matches. Discouraged in favor of locator.evaluate().
Upstream docs
selector
string
required
pageFunction
string
required
arg
unknown
result
unknown
Return value
await element.$eval('...', '...');

$$eval

Evaluate a function on all child elements matching the selector.
Discouraged in favor of locator.evaluateAll().
Upstream docs
selector
string
required
pageFunction
string
required
arg
unknown
result
unknown
Return value
await element.$$eval('...', '...');