"LOOP" Command
Description: This command is used to loop from Start to End with Step used as an increment and stores a Variable.
Usage Scenario: Suppose we want to add users to the Blacklist on our Reference app by looping through the steps that block users one by one.
Procedure: Define a step with Loop command that runs 4 times (Start: 1 / End: 4 / Step: 1) and after the loop step, add the steps that perform blocking the user. Your steps will look like this:
*NOTE: The steps that perform blocking the users have been set to “Continue on Failure” which prevents them from failing the entire test case if the number of the users to be blacklisted is less than 4.
The variable used in the field Loop No. Variable is important to pick carefully. For example, if you pick ‘i' as the Loop variable, the “i” will be assigned to the number generated by the loop. Then if you have a consequent step with an XPath such as “//a[@id=’Login]“, the i in @id will be replaced with the variable from the loop which causes automation to look an incorrect XPath. Suppose your loop finished at 3, the XPath will become: “//a[3d='Login']“ which will break your step.
See the Test Library path: subject7_samples/subject7_advanced_suite/subject7_add_user_to_blacklist