Selenium WebDriver 4

Locate an element with XPath

Easy30 pts~12 min
  • Locators
  • XPath
Practice app · Practice Catalog

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

Test URL
/lab/selenium-locate-an-element-with-xpath

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

Objective

Drive the search with XPath expressions.

Your task

  1. 1Open TEST_URL.
  2. 2Locate the field with //input[@placeholder='Search products'] and type “tee”.
  3. 3Locate the button with //button[@id='search-button'] and click it.
  4. 4Assert #search-summary contains “tee”.

Acceptance criteria

  • Elements are located with By.xpath
  • #search-summary mentions “tee”
  • At least 1 assertion passes

Selenium WebDriver 4 · Selenium · Locators & the DOM