Evaluate JavaScript
evaluateRun a JavaScript expression or function in the live page to inspect DOM details like computed styles, geometry, or element state when a snapshot is insufficient. Returns serializable results for deeper accessibility analysis.
Instructions
Evaluates a JavaScript expression or function in the session page via Playwright page.evaluate and returns its value. Use it to inspect the live DOM (computed styles, geometry, custom element state) when get_page_snapshot is not enough. The result must be serializable across the Playwright boundary; non-serializable or undefined values come back as null with serializable:false. This runs arbitrary page JavaScript — only evaluate code you intend to run.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| arg | No | Optional JSON-serializable value passed as the first argument when `expression` is a function. Ignored for plain expressions. | |
| sessionId | Yes | Session id returned by start_session. Required on every stateful tool call. | |
| expression | Yes | JavaScript evaluated in the page context. Either a plain expression (e.g. "document.title") or a function/arrow-function body (e.g. "() => document.querySelectorAll(\"a\").length", or "(n) => n + 1"). Functions are invoked with `arg`; plain expressions ignore it. Multi-statement logic needs a function body. |