Docs → RPA → CSS & XPath selectors
CSS & XPath selectors
Every command that touches the page needs to find it first. This is how selectors work, and which ones keep working.
CSS & XPath selectors
Anywhere a command takes a selector, you can use either a normal CSS selector or an XPath expression — XPath is auto-detected from its shape, no prefix needed:
| Pattern | Detected as |
|---|---|
//div[@id='x'] | XPath (absolute-ish) |
/html/body/div | XPath (absolute) |
./span | XPath (relative) |
../td[2] | XPath (parent axis) |
(//a)[1] | XPath (parenthesized, for indexing) |
| anything else | Plain CSS selector |
This means you can paste DevTools' "Copy XPath" output directly into any selector field with no changes.
Every element-targeting command (click, type, hover, select, focus, waitForSelector, extractText,
extractAttribute, getElementHtml, forElements) also takes an optional iframe selector — the
element commands run inside that <iframe>'s content instead of the top-level page, for
pages that embed a login form, payment widget, or CAPTCHA in a frame.