Skip to content
masterclass Buddy

Playwright · Matcher

toHaveCSS

toHaveCSS checks that a locator's element has an expected CSS property value. It retries until the value matches or the assertion timeout is reached.

Last updated

Syntax

await expect(locator).toHaveCSS(name, value)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • expect
  • locator
  • page.locator
  • expect.poll
  • expect.toPass

Source: Assertions | Playwright. Checked 2026-11-03.