Overview
A selector tells the executor which DOM element to interact with. Selectors use multiple fields as fallback strategies — the executor tries each in priority order until a match is found.Selector fields
| Field | Type | Priority | Description |
|---|---|---|---|
id | string | 1 | Element id attribute (most reliable) |
ariaLabel | string | 2 | aria-label attribute |
dataTestId | string | 3 | data-testid attribute |
dataAttributes | Record<string, string> | 4 | Other data-* attributes |
cssSelector | string | 5 | CSS selector |
xPath | string | 6 | XPath expression |
labelText | string | 7 | Associated <label> text |
innerText | string | 8 | Element inner text (max 200 chars) |
placeholder | string | 9 | placeholder attribute |
name | string | 10 | name attribute |
rect | object | 11 | Position-based fallback (last resort) |
tagName | string | — | HTML tag name (always present, used for filtering) |
role | string | — | ARIA role attribute |
inputType | string | — | type attribute of <input> elements |
Resolution pipeline
The executor resolves selectors through a 6-stage pipeline:Deterministic resolution
Tries each selector field in priority order (id → ariaLabel → … → name). No AI needed.
AI selector resolution
If deterministic resolution fails, AI analyzes the current page snapshot to find the target element.
Example
- Try
#submit-btnfirst - Fall back to
[aria-label="Submit form"]if the id is not found - Fall back to matching
innerTextif aria-label fails - Use
roleandtagNameas additional filters throughout
rect (position fallback)
Used as a last-resort deterministic strategy. Coordinates are relative to the viewport.
| Field | Type | Description |
|---|---|---|
x | number | X coordinate |
y | number | Y coordinate |
width | number | Element width |
height | number | Element height |
Position-based selectors are fragile — they break when the layout changes. Prefer semantic selectors (
id, ariaLabel, dataTestId) whenever possible.dataAttributes
Match elements by custom data-* attributes:
<div data-row-id="42" data-status="active">.
Best practices
- Prefer stable identifiers —
id,dataTestId, andariaLabelsurvive UI redesigns better than CSS selectors or XPath. - Avoid
rect— Position selectors break on any layout change. Only use them when no semantic selector exists. - Keep
innerTextshort — Long text matches are brittle. The field is capped at 200 characters. - Enable selector cache — For repeated executions,
--enable-selector-cachepersists successful resolutions across runs.