Manuals / Playwright with Python / Chapter 11
Part 2 · Core Interactions · beginner · ~60 min · Chapter 11 of 61
5. Locators Deep Dive
This is the most important chapter in the entire manual — nearly everything else builds on writing good locators. These are "user-facing" locators — they find elements the way a real user (or screen reader) would identify them, rather than by internal implementation details like CSS classes.
Step 1 of 13
Overview
This is the most important chapter in the entire manual — nearly everything else builds on writing good locators. These are "user-facing" locators — they find elements the way a real user (or screen reader) would identify them, rather than by internal implementation details like CSS classes. This is deliberate philosophy, not just convenience: implementation details (class names, DOM structure) change often as developers refactor CSS/markup, but the role and visible text of a button rarely change. Locators built on them break far less often.
Quick check
Preferred Playwright locator style is…
Chapter learning outcomes
- CSS and XPath locators
- Chaining and filtering locators
- Locator strictness and auto-retry
Clear these before you leave
Side quest
5. Locators Deep Dive deliverable
Apply one idea from “Overview” in a small script or note.