Skip to content

Testing with Bqurious > Actions

Loops

These keywords help us to execute a set of instructions in a loop.

Suppose you wish to execute a set for instructions within for loop.

Structure :

for <parameter>

<steps to execute>

endFor

ActionParametersExample Usage
breakFor Web, Mobile


---

To exit the for loop.
Example :
breakFor
Exits the for loop.
breakForEach Web, Mobile


---

To exit the forEach loop.
Example :
breakForEach
Exits the forEach loop.
endFor Web, Mobile


---

To end the for loop.
Example :
endFor
Ends the for loop.
endForEach Web, Mobile


---

To end the forEach loop.
Example :
endForEach
Ends the forEach loop.
for Web, Mobile


---

To execute the loop with starting index (mentioned in Parameter 1) and end index (mentioned in Parameter 2). Counter index will be stored in counter variable (mentioned in Parameter 3).
Param 1 : Index to start loop from Param 2 : Index to end loop Param 3 : Variable to store counter value inExample :
for : <Starting Index : 1> <Ending Index : 5> <Counter In Variable : counter>
Executes the for loop with starting index 1, ends the loop at index 5 and stores the counter value in variable counter.
forEach Web, Mobile


---

To execute the loop for each values (mentioned in Parameter 1). Parameter 2 will store the value at specific index. Counter index will be stored in counter variable (mentioned in Parameter 3).
Param 1 : Comma separated values to execute on Param 2 : Variable name to store the current value during execution Param 3 : Variable to store counter value inExample :
forEach : <Comma Separated Values : 00000001,000000002, 0000000003> <In Variable to Store Values : currValue> <Counter in Variable : counter>
Executes the loop for values 00000001,000000002, 0000000003 and stores counter index in counter variable. The actual value at counter index will be stored in currValue during execution.
updateLoopCounter Web


---

To update the loop counter variable with value (value mentioned in parameter 1) to set the data row to pick for next iteration.
Param 1 : Value to be updated in the loop counterExample :
updateLoopCounter : <Value to Update : 2>
Suppose you use for loop with starting index as 1, ending index as 8 and the counter value is stored in variable bqCounter.
The normal for loop should execute all the values one by one, if the starting index is 1 and ending index is 8. Now, let's update the counter value by 2 in the test script. The data for first row will be executed normally and the counter value will become 1. Now updateLoopCounter keyword will be executed and the counter value will be (1 + 2) = 3 So, the data for row 3 will be executed and the counter value will become 4. The updateLoopCounter keyword will be executed again and the counter value will be (4 + 2) = 6 This time, the data for row 6 will be executed and the counter value will become 7 and the loop is continued so on.