Loops are used for the purpose of executing repetitive actions in a test. With the help of the operations related to the Statements group, we can add such actions to the Keyword Test.
In this recipe, we will take up an example of clicking on one and the same button for several consecutive times with the help of the For Loop
.
First, let's record a simple script for further modification:
C:Program Files (x86)Microsoft Calculator PlusCalcPlus.exe
).For creation of the for
loop, it is first necessary to create a counter-variable:
counter
) and the type (Integer
), and click on Finish.counter
), Start Value (1
), and End Value (5
):The For Loop in the Keyword Test is workable in the same manner as the for
loop in any kind of programming. Specific actions, placed inside the loop, are executed for a pre-set amount of times. To assign a specific number of iterations, a loop variable is to be used (in our case, it is the counter
variable). During each iteration the value of the variable is incremented by the value of Step (we have left it to be equal to 1
by default). When the value of the loop variable is greater than the End Value, the loop execution is terminated.
In a similar way the While Loop and If...Then condition can also be created.
3.142.114.19