Skip to content
masterclass Buddy

Playwright · Matcher

toHaveId

toHaveId checks that a locator points to an element with a specific DOM id. It retries until the ID matches or the assertion times out.

Last updated

Since
v1.20

Syntax

await expect(locator).toHaveId(id, options);

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

Subscribe
  • expect
  • Locator
  • toHaveAttribute
  • toHaveRole
  • toHaveText

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