Table of contents
- Overview
- Creating a loop that repeats a fixed number of times
- Viewing test results
- Timeout and interval settings
- Limitations
Overview
The “Repeat until” command allows you to perform an action repeatedly until a given condition is satisfied. For example, if you want to repeatedly click on a button until a specific message shows up, you would use the “Repeat until UI element equals” command. As shown in the diagram below, the commands placed between the “Repeat until” command and the “End repeat” command will be executed repeatedly.
You can refer to the “Repeat” category in the command list to explore other available commands. Like the conditional branching commands, repeat commands can be nested.
Creating a loop that repeats a fixed number of times
To repeat a process a fixed number of times instead of waiting until a certain condition is satisfied, you can accomplish this by using arithmetic operations. As shown in the diagram below, you start by assigning an initial value to a variable, then define the loop condition so that the process repeats until that variable reaches a certain value, while incrementing the variable by 1 during each iteration. In this example, the process is set to repeat 10 times. Note that the loop terminates when X equals 10 (thus skipping the third line), which is why X is initialized at 0 rather than 1.
There are several additional points to consider when using this method:
- Under MagicPod’s specifications, except where it explicitly states “variable ~~”, any occurrence of a variable name must be enclosed in ${}. In this case, only the second argument in the arithmetic operation appears as ${X}. Also, the notation $X is not permitted.
- The variable’s value is not automatically reset once the loop finishes. If you use multiple repeat commands in one test case, assign a different variable or reset a variable’s value (for example, to 0 or 1) before each repeat command. Also, ensure that different variables are used when repeat commands are nested.
Viewing test results
On the test run detail page, the “Screenshots” tab displays the screenshots of the repeated steps in order of occurrence. Essentially, one screenshot is captured for every iteration; however, if there are too many iterations, some screenshots might be omitted. For additional information, please see the section Screenshot storage limits.
On the “Test run log” tab, the left and right areas display the information differently. The left area shows only one instance of repeated steps at a time, with the option to select a specific iteration via the dropdown menu. Meanwhile, the right area lists all the iterations, just like in the “Screenshots” tab.
In both tabs, the iteration count is indicated in parentheses following the step number. For example, “3(4)” indicates the 4th iteration of step 3.
When the loops are nested, “6(1.2)” indicates the 1st iteration of the outer loop and the 2nd iteration of the inner loop in step 6.
Timeout and interval settings
Click the down-arrow icon located at the end of the “Repeat until” command to reveal an area where you can set the timeout and the interval between iterations. The timeout specifies the maximum execution time for the entire loop, while the iteration interval is the delay between the end of the Nth iteration and the start of the (N+1)th iteration.
Depending on your specific requirements, adjust these values as needed. The current default, minimum, and maximum values are provided below:
default | minimum | maximum | |
timeout (sec) | 600 | 1 | 3600 |
interval (sec) | 5 | 1 | no limit |
Limitations
Screenshot storage limits
To prevent test results from retaining unnecessarily large amounts of data, when there are many iterations only the screenshots from the first 10 iterations and the last 10 iterations are saved. For example, if a “Repeat until” command executes 50 times, the screenshots from the 30 iterations in the middle will be omitted. This rule applies regardless of the number of steps within the “Repeat until” command.
Additionally, when the “Repeat until” commands are nested, the inner loop only saves 10 screenshots at the beginning and 10 at the end, regardless of the outer loop’s iteration count. For example, if the outer loop runs 20 times and the inner loop runs 2 times per outer iteration, then:
- Steps directly under the outer loop: Screenshots from all 20 iterations are saved
- Steps within the inner loop: Although there are 40 executions in total, only the first 10 and the last 10 screenshots (corresponding to the first 5 and the last 5 iterations of the outer loop) are saved
Visual diff approval
Within a “Repeat until” command, you can use the “Assert there is no visual diff” command; however, if visual diffs are found, a visual diff will be displayed for each iteration, and approving one will disable approval for the remaining ones. This limitation also applies to test cases using data patterns or shared steps.