Evaluate JavaScript
browser_evaluateRun custom JavaScript in a live page to read hidden state and return JSON-serialized results. Use it to extract values the accessibility tree doesn't expose.
Instructions
Runs JavaScript in the page and returns the JSON-serialized result. Accepts a bare expression ("document.title") or a function ("el => el.value"). When an element is targeted, it is bound to el. Use it to read state the accessibility tree does not expose.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| css | No | CSS selector, as an alternative to ref. | |
| ref | No | Element ref from the most recent snapshot, e.g. "e12". Preferred — refs are exact. Only valid for the page state that produced them. | |
| name | No | Accessible name to match alongside role. | |
| role | No | ARIA role, e.g. "button". Combine with name for an accessible-name match. | |
| index | No | Which match to use when the selector is ambiguous (0-based, default 0). | |
| maxChars | No | ||
| sessionId | Yes | Session id returned by browser_start. | |
| expression | Yes | Expression or function source to evaluate. |