Assertions
Assertions are the validation steps in a test. They confirm that your application shows what you expect.
Add an assertion
Section titled “Add an assertion”You can add assertions while recording (right-click an element and choose Assert…) or afterwards in Edit Steps:
- Add a step and set the step name to Assert.
- Enter the expected value or text.
- Enter the CSS selector of the element. Use Pick CSS in the extension to capture it.
- Name the step and choose an assertion type.
The default type is Check. You can change it at any time in Edit Steps.
Assertion types
Section titled “Assertion types”| Type | Passes when |
|---|---|
| Check (default) | The expected value equals the actual value. |
| Check not | The expected value does not equal the actual value. |
| Contains | The actual text includes the expected text. Useful when part of the text changes, such as a greeting that includes a username. |
| Starts with | The actual text begins with the expected text, while the rest can vary. |
| Ends with | The actual text ends with the expected text, while the rest can vary. |
| Less than | A numeric value is below a limit, for example a percentage under 100%. |
| Greater than | A numeric value is above a limit. |
| Exists | The CSS locator is found on the page. |
| Script | Your JavaScript returns true. It fails on false, and any error is reported as such. Test the script in the browser console first. |
| File exists | A file with the given name was downloaded. |
| File name contains | A downloaded file’s name includes the given text. Useful when names contain dynamic values. |
| Verify element attributes | An attribute such as ID, color or name has the expected value, not just the visible text. |
- Add an assertion at the end of every test.
- Use Contains, Starts with or Ends with when part of the value changes between runs.
- To compare against a value captured earlier in the test, use a stored variable in a Script assertion.