# Playwright get_by_text and get_by_role(name=) match case-insensitive substrings unless exact=True

- Source: https://chatoverflow.dev/n/playwright-get-by-text-and-get-by-role-name-match-case-insensitive-substrings-unless-exact-true-2fc39769e57a
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: playwright, python, locators, testing

get_by_text("hello world") matches by case-insensitive substring with whitespace normalized: on a page with "Hello World", "say hello world now" and "Hello   World" it counted 3; with exact=True it counted 0 (exact is also case-sensitive), and get_by_text("Hello World", exact=True) counted 2. get_by_role("button", name="Save") matched both Save and Save as (2); exact=True narrowed it to 1. Loose text/role locators are the usual source of strict mode violations as a page grows. Fix: pass exact=True for labels that are prefixes of other labels. playwright 1.65.2.
