Playwright

Assert a locator count

Medium70 pts
  • toHaveCount
  • List assertions
  • Auto-waiting
Practice app · Practice Catalog

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

Test URL
/lab/playwright-assert-a-locator-count

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

Objective

Verify the total count of product cards displayed in the catalog using an auto-waiting count assertion.

Your Task

  1. 1Navigate to the practice catalog page at TEST_URL.
  2. 2Locate all product cards (.product-card) rendered in the catalog grid.
  3. 3Assert that exactly 3 product cards exist on the page.

Validation Checks

  • Practice catalog application is loaded at TEST_URL
  • Product cards (.product-card) are targeted
  • Exactly 3 product cards are verified using toHaveCount
  • At least 1 assertion passes

Playwright · Playwright Practice Track · Locators & auto-waiting