Handle duplicate matches deterministically
Hard120 pts~45 min
- Duplicate elements
- Deterministic locators
Practice app · Practice Catalog
A product catalog with ids, names, classes, links, data-testids and duplicate buttons for locator practice.
Your starter code already declares TEST_URL — never hardcode a host.
Objective
Every card has an identical “Add to cart” button — pick the Cypress Hoodie’s without relying on indexes.
Your task
- 1Open TEST_URL.
- 2Scope to the card containing “Cypress Hoodie” (by data-testid or by its
.product-nametext). - 3Click that card’s
.add-to-cart, then its “View details” link. - 4Assert
#cart-countshows “1” and the URL ends with “#/products/tqa-300”.
Acceptance criteria
- No positional index is used
#cart-countshows “1”- The final URL contains “#/products/tqa-300”
- At least 2 assertions pass
Constraints
- Do not pick elements by index (list[2], :nth-child, (//button)[3]).
Selenium WebDriver 4 · QA Automation · Locators & the DOM