Selenium WebDriver 4

Use relative (friendly) locators

Medium70 pts~25 min
  • Relative locators
  • Selenium 4
Practice app · Practice Catalog

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

Test URL
/lab/selenium-use-relative-friendly-locators

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

Objective

Locate the search button by its position relative to the search field.

Your task

  1. 1Open TEST_URL and type “cap” into #search-input.
  2. 2Locate the button that is to the right of #search-input with a relative locator.
  3. 3Click it and assert #search-summary contains “cap”.

Acceptance criteria

  • A relative locator is used
  • #search-summary mentions “cap”
  • At least 1 assertion passes

Selenium WebDriver 4 · Selenium · Locators & the DOM