Do...Repeat If flow control - Selenium IDE
Do...Repeat If (expression) - Selenium IDE command
The part between Do and Repeat If (expression) is executed as long as the expression is true. RepeatIf uses executeScript_Sandbox to evaluate the expression. If the expression is false, the IDE executes the immediate next command Repeat If.
If PICTURE do THIS: This screencast uses repeat if to wait for an image, and do something once it appears.
Another Do... Repeat If example, this time we wait for a string:
Loop until keyword appears: This screencast uses
repeat if to stop the macro execution command once a keyword is found on website.
Ui.Vision reuses the established Selenium IDE flow control syntax
What is the difference between While...End and Do...RepeatIf?
The difference is that "while" is a top tested loop (test the condition first then do loop), but "do...repeatIf" is a bottom tested loop (do the loop then test the condition). So in the "worst case" scenario, the loop instructions inside the while loop are not be executed at all, but the loop instructions inside do...repeatIf loop are always executed at least once.
Note that Ui.Vision and Selenium IDE use RepeatIf and not RepeatUntil as in some other scripting languages.
Break and Continue
If you are working with loops, you might find it useful at some point to either break the loop when a certain condition is met or you might want to skip over one or more iterations of the loop. This is what the break and continue statements are used for.
Do/RepeatIf Example
For a real live example see this Do...RepeatIf use case in the forum: Loop until text shows up on the website. See also how to increment the Selenium IDE variable.
The example below is very basic.
Command | Target | Pattern/Text |
---|---|---|
open | https://ui.vision/ | |
Do | ||
echo | This command is executed once! | |
Repeat If | 100 < 5 |
Works in
Ui.Vision RPA for Chrome Selenium IDE, Ui.Vision RPA for Firefox Selenium IDE, Firefox IDE Classic
Related Demo Macros
DemoIfElse, DemoCsvSave
The ready-to-import-and-run source code of all demo macros can be found in the Open-Source RPA software Github repository.
See also
gotoLabel, Label, While, Times, executeScript, Web Automation Extension User Manual, Selenium IDE commands, Selenium IDE Flow Control (SelBlocks).
Anything wrong or missing on this page? Suggestions?
...then please contact us.