Selenium WebDriver 4

Find all matching elements and count them

Medium70 pts~25 min
  • findElements
  • Collections
Practice app · Practice Catalog

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

Test URL
/lab/selenium-find-all-matching-elements-and-count-them

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

Objective

Collect every matching element, assert the count and act on each one.

Your task

  1. 1Open TEST_URL.
  2. 2Use findElements with .product-card and assert there are 3.
  3. 3Collect all .add-to-cart buttons and click each one in a loop.
  4. 4Assert #cart-count shows “3”.

Acceptance criteria

  • findElements is used
  • #cart-count shows “3”
  • At least 2 assertions pass

Selenium WebDriver 4 · Selenium · Locators & the DOM