Selenium WebDriver 4

Write an attribute-based CSS selector

Medium70 pts~25 min
  • CSS selectors
  • Attributes
Practice app · Practice Catalog

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

Test URL
/lab/selenium-write-an-attribute-based-css-selector

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

Objective

Target elements purely by attributes such as placeholder, data-testid and aria-label.

Your task

  1. 1Open TEST_URL.
  2. 2Type “hoodie” into [placeholder='Search products'] and click #search-button.
  3. 3Assert #search-summary contains “hoodie”.
  4. 4Locate [data-testid='checkout'] and assert its aria-label is “Proceed to checkout”.

Acceptance criteria

  • Attribute selectors are used with By.cssSelector
  • #search-summary mentions “hoodie”
  • At least 2 assertions pass

Selenium WebDriver 4 · Selenium · Locators & the DOM