browser_run_code
Execute JavaScript functions in a browser tab using Playwright for web automation tasks.
Instructions
Run a Playwright JavaScript function against the specified tab.
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": "browser_run_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | A JavaScript function body or arrow function. It will receive page as the first argument. | |
| tab_id | No | Stable tab id from browser_tabs list; preferred when multiple agents run in parallel. Mutually exclusive with tab_index. | |
| tab_index | No | Tab index from browser_tabs list. If omitted, uses the lowest-index tab. Mutually exclusive with tab_id. |