playwright.expect.expect_to_have_class

playwright.expect.expect_to_have_class(loc, class_, *, timeout=None)

Expect a CSS class value is found.

This method wraps Playwright's Locator expectation to_have_class() method. However, Playwright does not have an easy method to check for individual class values within the elements class value.

This method will insert the class value into a regex pattern to check for the class value within the class attribute according to word boundaries or the start/end of the class string.

Parameters

Name Type Description Default
loc Locator The Playwright locator to check. required
class_ str The class value to find. required
timeout Timeout The maximum time to wait for the class to appear. None

See Also