execute_script
Runs JavaScript in the current browser page or an Appium mobile command with arguments, returning values or elements for custom automation tasks; use dedicated tools for standard clicks and typing.
Instructions
Runs JavaScript in the page (return a value; string args that match a selector are passed as elements) or, on Appium, a "mobile: " with args. Prefer the dedicated tools for clicks and typing.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"script": "<script>"
},
"name": "execute_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | Script arguments, or the mobile command's parameters | |
| script | Yes | JavaScript, or "mobile: <command>" on Appium | |
| session | No | Target session: map name or sessionId. Omit to use the default session. |