With variable assertions, you can validate the value of a variable against an expected value. Some common use cases for variable assertions include:
- Modifying a variable with mathematical operations or JavaScript, then asserting that it equals the expected value.
- Asserting on the expected value coming from a DataTable.
- Asserting on dynamic content that is not associated with an element on the page, such as the value of variable created from a custom JavaScript step.
Using variables in assertions
If you’re looking for more information on how to validate element properties according to a variable value, see the documentation onelement assertions.
Create and configure a variable assertion
In the mabl Trainer, click on ✔︎ (Assert) > Variable to add a variable assertion. Then define your assertion criteria:
- Variable: Select a variable from the dropdown.
-
Assertion type: Choose an assertion type. Supported assertion types for variables include:
- Equals
- Does not equal
- Contains
- Does not contain
- Starts with
- Does not start with
- Ends with
- Does not end with
- Greater than
- Less than
- Greater than or equals
- Less than or equals
- Matches regex
-
Expected value: When you select a variable, mabl displays its current value. You can edit this field as needed. To reference a variable, use mabl variable syntax:
{{@yourVar}}.
Click OK to save and apply the variable assertion to your mabl test.