Selectors & DOM
Struggling to target a specific button? Canβt get your dataset properties to extract the right text? You are in the right place.
This subcategory is dedicated to CSS selectors, XPath, handling dynamic elements, iframes, and Shadow DOMs.
When asking for help here, please provide:
- The Target URL β Crucial for us to inspect the page.
- The Selector you tried β e.g.,
css=.product-priceorxpath=//div[@id='main']. - HTML Snippet β If the page requires a login, paste a snippet of the HTML structure you are trying to target using code blocks (```).
- Expected vs. Actual Result β e.g., βI expected to get β19.99β but I got βnullβ.β
Quick Tips:
| Selector Type | When to Use | Example |
|---|---|---|
| Data Attributes | Best & most stable | [data-testid="price"] |
| ARIA Roles | Great for buttons/inputs | [role="button"][aria-label="Add to cart"] |
| Text Content | Simple one-off clicks | text="Log In" |
| Semantic HTML | Page structure | article h2 |
Avoid dynamically generated classes like
.css-1dbjc4nor.x1y2zβ they change on every deploy.