execute_script
Execute custom JavaScript in browser page context or Appium mobile commands to interact with DOM, trigger events, or run mobile actions when no dedicated tool is available.
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. |