Find an element by class name
Easy30 pts~12 min
- Locators
- By.className
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
Use a single class name to locate an “Add to cart” button and add a product.
Your task
- 1Open TEST_URL.
- 2Find the first element with class “add-to-cart” and click it.
- 3Assert
#cart-countshows “1”.
Acceptance criteria
- The button is located with By.className
#cart-countshows “1”- At least 1 assertion passes
Selenium WebDriver 4 · QA Automation · Locators & the DOM