Assertions

An introduction to assertions in mabl

Assertions are a fundamental component of testing; they help answer the question, "Is my application behaving as expected?"

At a high level, a browser test consists of the following:

  1. An action in the application under test, such as clicks, entering text, and visiting a URL.
  2. Assertion(s) to verify that the previous actions yielded the expected result.

For example, after taking the actions to log into an application, a good assertion would validate that these actions yielded the expected results. In this instance, after logging in, the assertion validates that the username appears on the page.

600600

Recording assertions

When you create an assertion, you define the logic mabl should use to confirm that your application is in the correct state at a specific step in a test run. In a mabl browser test, you can make assertions against the following:

Detailed information and steps for each type of assertion can be found in the links listed above.

586586

Example of an element assertion

📘

Assertion character limit

Assertions have a character limit of 300. If you are trying to assert on an element that has more than 300 characters, mabl will capture only up to 300 characters.

Assertions and auto-heal

For any recorded step in a mabl browser test, if the target element cannot be found during the test run using the attributes mabl already knows about it, mabl will look for similar elements using auto-heal in an attempt to find the correct element after potential changes. While there are some nuances to this process, the basic a basic level the rules are as follows:

  • If the test passes, the auto-heal is saved.
  • If it fails, the auto-heal is not saved.

Assertions are an important part of this process. They help ensure that auto-healed test steps are still identifying the correct element. Just as important, assertions help prevent tests from auto-healing to the wrong element. If the assertion (and the test) fails, the auto-heal doesn't get saved.

Assertions, auto-heal, and Configure Find

If you want to create a recorded assertion that checks whether something "is present" or "is not present", you can use Configure Find to specify which attributes are the most important and the time that mabl should wait for a matching element (up to 15 minutes). When you set up Configure Find, you will also need to indicate whether or not you want mabl to use auto-heal to widen its search if it doesn't find the target in time.

If an "is present" or "is not present" assertion uses auto-heal, you should keep in mind the following:

  1. If an "is present" assertion auto-heals to a different element that matches Configure Find settings, the assertion will pass.
  2. If an "is not present" assertion auto-heals to a different element that matches the Configure Find settings, the assertion will fail.

This behavior could result in false passes and false failures. If you do not want an assertion to auto-heal to a different element, you can select Fail this step. This setting disables auto-heal.

296296

The "Fail this step" setting disables auto-heal.

Disable case sensitivity

If you check "disable case sensitivity", mabl checks that the value matches what you expect without regard to what letters are in uppercase or lowercase.

For example, if your application displays names in all capital letters in some parts ("SMITH") and only partially capitalized in other parts ("Smith"), then case insensitive assertions could be used to validate the the same name is being displayed in both areas.

📘

Note

The "disable case insensitivity" option may behave unexpectedly for certain characters and languages where casing exists and the rules differ significantly from standard English.

For example, some languages use the dotted uppercase I character "İ", which will not necessarily be considered equivalent to the dotted lowercase "i" with case sensitivity disabled.

Continue on failure

If you check "Continue on failure", the assertion will pass regardless of whether the element meets the assertion criteria. If the step does not pass in a cloud run, it will show a warning instead of a failed step.

11141114

Example of an assertion that continued on failure.

🚧

Continue on failure does not fail tests

Continue on failure is mabl's current implementation of a "soft assertion." If the assertion fails, it will still mark the test as passed. The only way to know what happened in a "continue on failure" assertion is by reviewing the individual cloud run.


Did this page help you?