Choose CSS over brittle absolute XPath
Medium70 pts~25 min
- Locator strategy
- Maintainability
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
Rewrite a legacy absolute XPath (/html/body/…) as a short, intention-revealing CSS selector.
Your task
- 1Open TEST_URL.
- 2Open the Cypress Hoodie details using
[data-testid='product-tqa-300'] .details-link— no path from /html. - 3Assert the URL ends with “#/products/tqa-300”.
Acceptance criteria
- No absolute XPath is used
- A CSS selector is used
- The final URL contains “#/products/tqa-300”
- At least 1 assertion passes
Constraints
- Do not use absolute XPath expressions starting with /html.
Selenium WebDriver 4 · Selenium · Locators & the DOM