execute_script
Execute custom JavaScript in browser pages or Appium mobile commands to manipulate DOM, trigger events, or perform app/device actions when dedicated tools do not cover 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. |