Playwright

Chain locators to scope a search

Medium70 pts
  • Locator Chaining
  • Scoped Search
  • Avoiding Duplicates
Practice app · Practice Catalog

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

Test URL
/lab/playwright-chain-locators-to-scope-a-search

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

Objective

Chain locators together to scope an action within a specific card, avoiding duplicate element conflicts.

Your Task

  1. 1Navigate to the practice catalog page at TEST_URL.
  2. 2Locate the product card with test identifier 'product-tqa-200' ('Playwright Tee').
  3. 3Within that specific card, locate and click the 'Add to cart' button (.add-to-cart).
  4. 4Assert that the cart counter (#cart-count) increments to '1'.

Validation Checks

  • Practice catalog application is loaded at TEST_URL
  • Action is scoped to the product card with test identifier 'product-tqa-200'
  • 'Add to cart' button within the card is clicked
  • Cart counter (#cart-count) displays '1'
  • At least 1 assertion passes

Playwright · Playwright Practice Track · Locators & auto-waiting