Skip to main content

Assertions

We recommend adding a lot of assertions to your tests. Assertions can be used to verify that you are on the right page, that the page contains the right elements, and that the elements contain the right values.

Fail Fast

Assertions have the benefit of being able to fail fast. If an assertion fails, the test will stop and the error will be reported. This is much better than the test continuing and failing later on or when for example the test tries to interact with an element that is not there.

We recommend adding an assertion after every navigation or redirect to ensure that you are on the expected page.

Less Flakiness

Assertions can also help with flakiness. They slow down the test and give the page time to load. This can help with flakiness caused by the page not being fully loaded when the test tries to interact with it.

Available Assertions

Step typeDescription
checkForErrorsChecks for various types of errors on the current page.
containsTextChecks if a given element's text contains the given text.
hasAttributeChecks if a given element has a given attribute with a given value (optional).
hasClassChecks if a given element has one ore more classes.
hasTextChecks if a given element has the given text.
hasValueChecks if a given element has a value-attribute with the given value.
interactiveTableCellHasTextCheck whether an Interactive Grid/Report cell has a given text or not.
isDisabledChecks if a given element has the "disabled" attribute or is disabled via "aria-disabled".
seeElementCheck if a given element is visible.
seeInCurrentUrlCheck if a given value is present in the current URL.
note

Most assertion steps are listed in the Assertion category. A few steps are listed in others, for example interactiveTableCellHasText which can be found in the Interactive Table category.