Pick a Playwright locator
Choose how to find the Add task button, then see which page changes break each choice.
The diagram
Tom wants one line that finds the Add task button in Daily List. Choose a way to find it. Then read which ordinary page changes it survives.
page.getByRole('button', { name: 'Add task' })
- ✓ Still works: A designer renames the CSS class
- ✓ Still works: A new element is added above it, so its position moves
- ✗ Breaks: The visible words change from “Add task” to “Create task”
- ✓ Still works: A second, similar button “Add list” appears beside it
3 of 4 changes survived. It asks for what a user sees: a button called “Add task”. It survives restyling and re-ordering, and it fails loudly when the words change, which is a real change a test should notice.
SYNTHETIC / TRAINING ONLY. The Daily List app and the people in it are made up, and every number is a teaching figure.
What this shows
Locators: a locator that describes what a user sees survives restyling and re-ordering, and one tied to position or styling breaks.