browser_eval
Evaluate JavaScript expressions in browser tabs to read page state, scroll content, or trigger DOM changes using Chrome DevTools Protocol integration.
Instructions
Evaluate a JavaScript expression in a browser tab and return the result. Use for reading page state, scrolling, or triggering simple DOM mutations. Pass lensId (from perception_register) to verify tab identity and readyState before evaluating and receive post.perception state feedback without a screenshot. Caveats: Returns JSON-serializable values only — DOM nodes cannot be returned directly. React / Vue / Svelte controlled inputs cannot be updated via element.value = ... or native-setter + dispatchEvent — the framework's internal state is not refreshed; use keyboard_type (click the field first, pass windowTitle) for such form fields.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expression | Yes | JavaScript expression to evaluate in the browser tab | |
| tabId | No | Tab ID from browser_connect. Omit to use the first page tab. | |
| port | No | Chrome/Edge CDP remote debugging port. | |
| includeContext | No | When true, append activeTab and readyState context to the response. | |
| lensId | No | Optional perception lens ID. Guards (target.identityStable) are evaluated before eval. Note: browser_eval returns raw text, so no perception envelope is attached (guards only). |