Conditional Blocks
Overview
A conditional block combines (1) an observe action looking for a particular condition in your app, and (2) any actions that should execute if the condition is met. If the condition isn't met, Rainforest will skip those conditional actions and continue with the rest of the test.
Conditional blocks are great for handling things that appear inconsistently in your app, like:
- Closing random popups
- Cleaning up spoiled test data resulting from a prior test run failing to reach a data-reset step
How it works
To add a conditional block:
- Set the condition. Specify whether dependent actions should be completed if something is either visible or not visible.
- Adjust the time limit up or down as needed. Rainforest will only wait up to the time limit to evaluate the condition.
- Add dependent action(s) to the block that'll only be executed if the condition is met.
Previewing and reviewing results
During all previews and test runs, the conditional assertion (i.e., the "If" statement) will always pass. It will either be true or false.
From the results page, you can see whether the conditional assertion resolves to true or false. You’ll also see that dependent actions have been skipped, passed, or failed using the following icons:
Icon | Meaning |
---|---|
The conditional step was true | |
The conditional step was false | |
The step was skipped | |
The step passed | |
The step failed |
FAQs:
Is there any limit to the number of conditional blocks in a test?
- No.
Can I nest a conditional block in a reusable snippet or a snippet within a conditional block?
- Yes, both are supported.
Can I nest conditional blocks within conditional blocks?
- Yes, you can, though this may make your test more difficult for other users to understand.
Are there limits to how many levels I can nest?
- No, but we don't recommend going more than four levels of conditional blocks deep, because your test may become needlessly complex and difficult to understand.
If you have any questions, reach out to us at [email protected].
Updated 8 months ago