1. Locator Based.

Assertions For Items On Page.

await expect(locator).function

Function Description
.toBeChecked() Checkbox is checked
.toBeDisabled() Element is disabled
.toHaveJSProperty() Element has a JavaScript property
All true for the following item:
Checkbox

.toBeEditable() Element is editable
.toBeEmpty() Container is empty
.toBeEnabled() Element is enabled
.toBeVisible() Element is visible
.toBeFocused() Element is focused
.toHaveId() Element has an ID
All true for the following item:

Function Description
.toContainText() Element contains text
.toHaveText() Element matches text
All true for the following item:

Function Description
.toHaveValue() Input has a value
.toHaveAttribute() Element has a DOM attribute
All true for the following item:

Function Description
.toHaveValues() Select has options selected
All true for the following item:

Function Description
.toHaveCount() List has exact number of children
.toHaveClass() Element has a class property
.toHaveCSS() Element has CSS property
.toHaveScreenshot() Element has a screenshot
All true for the following item:
  • Coffee
  • Tea
  • Milk

Function Description
.toBeHidden() Element is not visible
All true for the following item:

hidden paragraph between arrows below

-->

<--


2. API Based.

Assertions for network.

Function Description
expect(apiResponse).toBeOK() Response has an OK status

3. Page Based

Assertions For The Page.

await expect(page).function

Function Description
.toHaveTitle() Page has a title
.toHaveURL() Page has a URL
.toHaveScreenshot() Page has a screenshot



See..
https://playwright.dev/docs/test-assertions