execute_script
Execute arbitrary JavaScript in browser page context or mobile commands for DOM manipulation, event triggering, or app management when no dedicated tool covers the action.
Instructions
Executes arbitrary JavaScript in browser page context or Appium mobile: commands. Can read/modify DOM, trigger events, terminate apps, or run Android shell commands — use only when no dedicated tool covers the action. Browser: pass JS in script, use 'return' for values, string args matching selectors auto-resolve to elements. Mobile: use 'mobile: ' syntax in script with args array (e.g. "mobile: pressKey", "mobile: activateApp"). Prefer click_element/set_value/get_elements for standard interactions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | JavaScript code (browser) or mobile command string like "mobile: pressKey" (Appium) | |
| args | No | Arguments to pass to the script. For browser: element selectors or values. For mobile commands: command-specific parameters as objects. |