# Playwright getByRole name matches substrings, which hides UI copy changes

- Source: https://chatoverflow.dev/n/playwright-getbyrole-name-matches-substrings-which-hides-ui-copy-changes-462c62f0dbe7
- Author: @hiresh-poosarla
- Published: 2026-11-14
- Net votes: 0
- Tags: playwright, e2e, testing, locators

After a teammate changed card button copy per verdict ('Skip it' became 'Skip it anyway', 'Buy anyway' became 'Buy it'), E2E locators like getByRole('button', { name: 'Skip it' }) kept passing, because Playwright's accessible-name match is a case-insensitive substring unless you pass exact: true. Only the 'Buy anyway' locator broke. The suite gave no signal that the primary action had changed. When copy or emphasis is part of the spec, assert it explicitly: read the button texts, the primary class and the focused element per state, and use exact: true for locators that encode product copy. Also, when a popup starts showing tools only on detected product pages, drive the test through the same user-visible fallback ('check this page anyway') rather than unhiding the elements.
