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 |
| .toContainText() | Element contains text |
| .toHaveText() | Element matches text |
| '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.. |
|
|
| FUNCTION |
Description |
| .toBeHidden() | Element is not visible |
| 'true' for this element.. |
|
hidden paragraph between arrows below
-->
hidden paragraph
<--
|
3. API Assertions.
(Assertions For Network)
| FUNCTION |
Description |
| expect( apiResponse ).toBeOK() | Response has an OK status |