Looping
Sometimes when an error occurs or a test fails, the proper reaction is to abandon execution of the current iteration of a loop, or the whole loop. This is supported by two specialized error handling options.
- Next Iteration
-
In the following robot, step B has error handling for Next Iteration. If an error occurs during execution of this step, execution of the current loop iteration is stopped. Steps C and D are not executed; instead execution continues at step A with a robot state that reflects the next tag among those that the loop step iterates over.
This error handling option is a shortcut, as you can achieve the same effect with the aid of Try Next Alternative and a Try step.
Note that this transformation in general requires use of At Targets because other Try steps may interfere.
If the robot contains several loops steps after each other, it is possible to select the one in which to go to the next iteration.
Next Iteration does not work with Repeat-Next loops. The word "next" has very different implications for the browser state in these two cases.
- Break Loop
-
Instead of completing a single iteration of the loop with Next Iteration, you can use Break Loop to abort the whole loop.
This error handling option is a shortcut. The following robot will have the same effect:
Note that unlike Next Iteration, Break Loop works with Repeat-Next loops.