dom.set_attribute
Set or remove an HTML attribute on a selected page element, using CSS selectors, XPath, snapshot refs, or IDs to target it.
Instructions
Set or remove an attribute on an element.
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": {
"name": "<name>"
},
"name": "dom.set_attribute"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nth | No | Zero-based index when the locator matches several elements. | |
| ref | No | Snapshot ref (eNN) from page.snapshot. | |
| name | Yes | ||
| text | No | Visible text of the element. | |
| value | No | ||
| xpath | No | XPath expression. | |
| remove | No | ||
| frame_id | No | Frame to search within; see page.list_frames. | |
| selector | No | CSS selector; pierces shadow DOM. | |
| target_id | No | Target handle (tgt_*). Omit for the active page. | |
| browser_id | No | Browser handle (br_*). Omit to use the only running browser, or auto-launch one. | |
| backend_node_id | No | CDP backendNodeId, e.g. from inspector.pick. |