Working with loops in testRigor
Loops are a step or a sequence of steps that will be repeated continually until a certain condition is met.
Loops are useful for several different scenarios. For instance, it’s commonly necessary to scroll through very long pages until a certain text is visible or a certain button is visible.
In testRigor, we trigger a loop with the keyword until
.
scroll down until page contains "Submit" until page contains stored value "previously generated id"
click "Next" until page contains "Tom" click "Tom"
click "Next" up to 12 times until page contains "Tom"
Loops with Reusable Rules
Reusable rules can also be used in loops. You may need to group certain actions to be used in a loop, or there may be certain actions that are not currently supported in a loop. By putting that sequence of actions or the unsupported action into a rule, we can force it to loop.
An example of a command that is not currently supported in a loop is go back
. However, if you use it as a single line in a reusable rule and name the rule something different from the step itself (for instance go back rule
), loops will work.
go back until page contains "Welcome to homepage!"
go back rule until page contains "Welcome to homepage!"
IMPORTANT NOTE: The maximum amounts of time testRigor can execute a loop is 42.
Reference link: For more info about Loops in testRigor, go here.