execute_js
Execute JavaScript in the page context to retrieve data or trigger interactions that CSS selectors cannot handle. Returns the evaluation result as JSON.
Instructions
Execute arbitrary JavaScript in the page context and return the evaluation result. The script runs synchronously in the browser's main frame with full access to the DOM, window, and page APIs. Use as a last resort when CSS selectors and other tools cannot achieve the interaction — prefer click, fill_form, and select_option for standard interactions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | JavaScript code to execute in the page context. The return value of the last expression is serialized as JSON and returned. For async operations, use 'await' (the script is wrapped in an async function). Example: "document.title" or "await fetch('/api/data').then(r => r.json())". |