Selenium WebDriver 4

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.

Test URL
/lab/qa-automation-choose-css-over-brittle-absolute-xpath

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

  1. 1Open TEST_URL.
  2. 2Open the Cypress Hoodie details using [data-testid='product-tqa-300'] .details-link — no path from /html.
  3. 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 · QA Automation · Locators & the DOM