Playwright · Matcher
toHaveText
Checks that a locator's element or elements have the expected text. It supports strings, regular expressions, and ordered arrays of expected values.
Last updated
- Since
- v1.20
Syntax
await expect(locator).toHaveText(expected, options);In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
LocatorexpecttoContainTexttoHaveValuetoHaveAttribute