Test Automation / Quiz

Locator Strategy Showdown

data-testid vs CSS vs XPath vs role-based, pick locators that survive refactors instead of breaking every sprint.

Difficulty
Easy
Format
Quiz
Points
100
Estimate
7 min

// MISSION BRIEF

Your Mission

Half of all automation maintenance is fixing broken locators. This quiz tests whether you pick selectors that survive UI refactors, or ones that shatter when a designer breathes on the CSS.

Assume a modern web app (React) tested with Playwright or Selenium.

// FIRST CONTACT

Battle teaser

Which locator is MOST resilient to UI refactors for a submit button?

  1. A//div[@class='checkout']//button[3]
  2. Bdiv.checkout > div:nth-child(3) > button.btn-primary
  3. CgetByRole('button', { name: 'Place Order' })
  4. Dbutton.css-1x8fh3z
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

locatorsplaywrightseleniumselectors