Selenium WebDriver 4

Build a resilient checkout locator

Medium70 pts~25 min
  • Resilient locators
  • data-testid
Practice app · Practice Catalog

A product catalog with ids, names, classes, links, data-testids and duplicate buttons for locator practice.

Test URL
/lab/selenium-build-a-resilient-checkout-locator

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Click Checkout with a locator that survives styling and layout changes.

Your task

  1. 1Open TEST_URL and add one product with the first .add-to-cart button.
  2. 2Locate Checkout by [data-testid='checkout'], its aria-label “Proceed to checkout” or its id — not by position or styling classes.
  3. 3Click it and assert the status text “Checkout started with 1 item” is displayed.
  4. 4Assert #cart-count shows “1”.

Acceptance criteria

  • Checkout is located by a stable attribute
  • No absolute XPath is used
  • #cart-count shows “1”
  • At least 2 assertions pass

Selenium WebDriver 4 · Selenium · Locators & the DOM