Run JavaScript
evaluateRun JavaScript in a browser tab to extract data or execute custom scripts, returning JSON results; choose main or isolated world and target iframes as needed.
Instructions
Runs JavaScript in the page and returns the result as JSON. Pass either an expression ("document.title") or a function ("(a, b) => a + b") with args. Promises are awaited. DOM nodes, functions and cyclic objects are described instead of failing. world="isolated" runs in a private world that cannot see page globals; frame selects an iframe by the ref of its element.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | Arguments for function. | |
| frame | No | Element ref from page_snapshot or find, e.g. "e12". | |
| tabId | No | Tab to act on. Defaults to the session target tab (see tab_select). | |
| world | No | Execution world (default main, i.e. the page's own JavaScript context). | |
| function | No | JavaScript function source, called with args. | |
| timeoutMs | No | Timeout in milliseconds (default 30000). | |
| expression | No | JavaScript expression to evaluate. | |
| userGesture | No | Treat the call as a user gesture (allows play(), fullscreen, clipboard). |