Manuals / Selenium WebDriver / Chapter 4

B · Stability · intermediate · Week 2–3 · Chapter 4 of 12

Locators & stability patterns

Stable locators and stable tests. Page Factory optional — clarity over magic. data-testid agreements with dev.

Path progress
27%

Step 1 of 4

Locator priority doc

ID → data-testid → CSS → XPath last. Document in SELECTORS.md.

Locator priority docDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Locator priority ddrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Do this now

Refactor 3 XPath locators to CSS or ID on the-internet pages.

Was this step clear?
Chapter learning outcomes
  • Locator priority
  • Stale element handling
  • Iframe and window switches

Clear these before you leave

Side quest

Locator audit

List every locator in suite. Flag brittle ones. Fix top 3.