Filter locators by text and has
Medium70 pts
- locator.filter
- hasText
- has option
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
Filter a collection of matching locators by text content and interact with the filtered item.
Your Task
- 1Navigate to the practice catalog page at TEST_URL.
- 2Locate all product cards (.product-card) and filter them to find the card containing the text 'Cypress Hoodie'.
- 3Click the 'Add to cart' button within that filtered card.
- 4Assert that the cart counter (#cart-count) displays '1'.
Validation Checks
- Practice catalog application is loaded at TEST_URL
- Product cards are filtered using
.filter({ hasText: ... })or.filter({ has: ... }) - 'Add to cart' button inside the filtered card is clicked
- Cart counter (#cart-count) displays '1'
- At least 1 assertion passes
Playwright · Playwright Practice Track · Locators & auto-waiting