How to Use Loops?

Loops are used to repeat a scenario a specified number of times.

Example: RunScenario My Scenario -Repeat 60
Description: Repeat My Scenario 60 times.

Example:

Like posts about Test Automation on Twitter

Save the below steps as a new scenario named 'Like Posts’. This will repeat like action on Twitter.

Scroll 3 -UntilVisible Image {HeartIcon}
Click Image {HeartIcon}
IsVisible Text “Unlike”

To like all posts about a topic on Twitter, our main scenario that will perform the liking action would be as follows.

OpenBrowser Chrome “x.com” -Incognito false
ClickAndWrite Text “Search” “Test Automation”
SendKeys ENTER
Wait Text “People”
RunScenario Like Posts -Repeat 20

After performing 20 likes, if you add steps to continue the scenario, you can add ‘-WhenFails Continue’ option as an example below. If the RunScenario steps fail, the execution will continue.

OpenBrowser Chrome “x.com” -Incognito false
ClickAndWrite Text “Search” “Test Automation”
SendKeys ENTER
Wait Text “People”
RunScenario Like Posts -Repeat 20 -WhenFails continue
Click Text “Home”
IsVisible Text “What is happening”

1 Like

Some hiccup before this scenario when using -WhenFails continue, can’t stop execution in the middle (even though I tried and restart the agent), changes in the steps are executed after the loops are done. Just be careful :slight_smile:

Testing -Repeat 100 now (success).

I can only see the loops details after it ends

Feedback, would like to know/see how many loops left/current running loops xx and btw, timed out warning is a false alarm, didn’t change only after the scenario ends.