Locator And Assertion Defaults
Pack:
playwrightParent skill: Playwright Locators Assertions And User Visible Contracts Source:playwright/playwright-locators-assertions-and-user-visible-contracts/references/locator-and-assertion-defaults.mdDefault locator order:
getByRolegetByLabelgetByPlaceholdergetByTextgetByTestIdonly when semantics are weak or intentionally absent
Default assertion posture:
- assert user-visible outcomes
- use
expect(locator)rather than manual polling - wait on the state that matters, not on time passing
Good reasons for test IDs:
- non-semantic drag handles
- repeated controls with identical accessible names
- UI with intentionally unstable copy
Bad reasons for test IDs:
- habit
- avoiding accessible markup work
- trying to bypass unstable synchronization