Execute JavaScript
execute_jsExecute JavaScript code directly in browser pages to interact with elements, fill forms, or call functions for debugging and automation tasks.
Instructions
Execute JavaScript code in the page context. Returns the result of the expression. Useful for clicking buttons, filling forms, or calling page functions.
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": {
"code": "<code>"
},
"name": "execute_js"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript code to execute in page context | |
| targetIndex | No | Target index from list_targets | |
| port | No | Chrome CDP port |