browser_evaluate
Execute JavaScript in the active browser tab for shadow-DOM traversal, reading window state, or programmatic clicks during automation.
Instructions
Execute JavaScript in the active tab via CDP Runtime.evaluate. Returns a serialized value (or {ok:false,error} on exception). Useful for shadow-DOM traversal, reading window state, or programmatic clicks when extensions intercept the synthetic mouse events. The expression is run in the page context as a real user gesture.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"expression": "<expression>"
},
"name": "browser_evaluate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expression | Yes | JS expression. Wrap statements in an IIFE if needed: `(()=>{ ... return value; })()`. | |
| awaitPromise | No | If the expression returns a Promise, await it before returning. | |
| returnByValue | No | Serialize the result. Set false to get an opaque objectId for later use (rare). | |
| timeoutMs | No | ||
| tabId | No |