EZ Example - Assertions


1. WebPage Assertions.

(Assertions For WebPage)

await expect( page ).FUNCTION

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


2. HTML Element Assertions.

(Assertions For Elements On Page)

await expect( my_element ).FUNCTION

FUNCTION Description
.toBeChecked()Checkbox is checked
.toBeDisabled()Element is disabled
.toHaveJSProperty()Element has a JavaScript property
'true' for this element..
Checkbox

FUNCTION Description
.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
'true' for this element..

FUNCTION Description
.toContainText()Element contains text
.toHaveText()Element matches text
'true' for this element..

FUNCTION Description
.toHaveValue()Input has a value
.toHaveAttribute()Element has a DOM attribute
'true' for this element..

FUNCTION Description
.toHaveValues()Select has options selected
'true' for this element..

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
'true' for this element..
  • Coffee
  • Tea
  • Milk

FUNCTION Description
.toBeHidden()Element is not visible
'true' for this element..

hidden paragraph between arrows below

-->

<--


3. API Assertions.

(Assertions For Network)

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