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.
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 |