Playwright

Assert element count

Medium70 pts
  • toHaveCount
  • Element Collections
  • Assertions
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-element-count

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

Objective

Assert the total number of product card elements rendered in the practice catalog.

Your Task

  1. 1Navigate to the practice catalog page at TEST_URL.
  2. 2Locate all product cards (.product-card) in the catalog grid.
  3. 3Assert that the total count of product cards is exactly 3.

Validation Checks

  • Practice catalog page is loaded at TEST_URL
  • Product cards (.product-card) are targeted
  • Count of product cards verified as exactly 3
  • At least 1 assertion passes

Playwright · Playwright Practice Track · Assertions