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

loc: Locator

The Playwright locator to check.

class_: str

The class value to find.

timeout: Timeout = None

The maximum time to wait for the class to appear.

See Also