Playwright · Matcher
toHaveAttribute
Checks that a locator's element has a named attribute. It can compare the value, match a regular expression, or check only that the attribute exists.
Last updated
- Since
- v1.20
Syntax
await expect(locator).toHaveAttribute(name, value, options);In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
LocatorLocatorAssertions.nottoHaveTexttoHaveClassgetAttribute