Playwright · Matcher
toHaveClass
Use expect(locator).toHaveClass() to verify an element's CSS class property. The assertion retries until the expected class condition passes or the assertion timeout is reached.
Last updated
Syntax
await expect(locator).toHaveClass(expected);In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
expectLocatortoHaveTexttoBeVisibleexpect.pollexpect.toPass