query_dom
Query DOM elements using CSS selectors or XPath expressions to retrieve tag, attributes, text, and position. Supports pagination and shadow DOM piercing.
Instructions
Query DOM elements via CSS selector or XPath. Returns tag, attributes, text, position. CSS results include a ref field for use in subsequent calls.
When to use: Precise element lookup by CSS selector or XPath when you know the exact selector. When NOT to use: Use find for natural-language element search or read_page for full DOM structure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tabId | Yes | Tab ID to query | |
| method | Yes | Query method: css or xpath | |
| selector | No | (css) CSS selector | |
| xpath | No | (xpath) XPath expression | |
| multiple | No | Return all matches. Default: false | |
| pierceShadow | No | Search inside shadow DOM when no results in light DOM. Default: true | |
| limit | No | (multiple) Max results per page. Defaults to 50 for CSS/XPath. | |
| cursor | No | Opaque pagination cursor returned as nextCursor from a prior query_dom multiple-result call. |