Execute JavaScript
chrome_execute_scriptRun custom JavaScript in the current browser page to check application state, test UI behavior, or extract data from web content.
Instructions
Execute custom JavaScript in the browser context.
Runs arbitrary JavaScript code on the current page. Useful for custom testing scenarios or data extraction.
Args:
script (string): JavaScript code to execute (required)
args (array): Arguments to pass to the script (optional)
Returns: Result of the script execution.
Examples:
Get element count: { script: "return document.querySelectorAll('.item').length" }
Check state: { script: "return window.myApp.isReady" }
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": "chrome_execute_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | Arguments to pass to the script | |
| script | Yes | JavaScript code to execute in the browser context |