Looping Statement
Looping statements in SimplifyQA allow users to repeat a set of test steps multiple times until a specific condition is met. This is useful when testing scenarios that require iterative execution, such as validating multiple inputs, handling dynamic UI elements, or automating repetitive tasks.
Types of Looping Statements in SimplifyQA
SimplifyQA supports the following looping mechanisms:
FOR Loop
WHILE Loop
DO-WHILE Loop
FOR Loop
FOR Loop is used when the number of iterations is known beforehand. It allows users to execute a test case for a defined number of times.
Example:
Suppose we need to create 5 user accounts in a web application.
FOR Loop will repeat the account creation steps 5 times.
How to add FOR Loop in SimplifyQA?
Navigate to the test case and click on "Add Step" Dropdown.
Choose the 'FOR Loop' block.
Click on the condition icon to define the condition and parameters.
Define a loop count.
Specify the test steps to execute in each iteration.
The loop terminates after the defined iterations are complete.
In the provided interface for adding conditions for a For Loop in SimplifyQA, the following parameters need to be configured:
Initialisation
Parameter: This is where you define the starting point of the loop. Usually, you initialise a loop variable.
Operator: Set this to "equal to" (=) as you assign an initial value to the loop variable.
Parameter/Value: Enter the starting value for the loop (e.g., i = 0).
Description: Provide a brief description of the purpose of this initialisation step, such as "Initialise the loop counter."
Condition
Parameter/Object: Define the loop variable or object being evaluated (e.g., i). Type '#' to select object and '/' to select parameter.
Operator: Specify the condition that must be true for the loop to continue.
Parameter: Set the comparison value (e.g., 10 if the loop should run until i is less than or equal to 10).
Condition: Choose a logical operator (e.g., AND, OR) if combining multiple conditions.
Description: Add context for this condition, such as "Run until the counter reaches 10."
Increment/Decrement
Parameter: Select the loop variable (e.g., i).
Inc/Dec: Choose whether the loop variable increments (e.g., i++) or decrements (e.g., i--) after each iteration.
Description: Provide a short explanation, such as "Increment the counter by 1."
While Loop
The While Loop is used when the number of iterations is not known beforehand and depends on a condition being met.
Example:
Checking if an email verification code appears in an inbox.
The loop will continue checking until the verification code is received.
How to add WHILE loop in SimplifyQA:
Set a condition for the loop.
If the condition remains true, the loop continues execution.
The loop exits once the condition is false.
For a While Loop, you need to define a condition that will be checked before each iteration. The loop will continue executing as long as the condition remains true.
Parameters to be Added for a While Loop:
Parameter (Loop Condition)
Define the variable or parameter that controls the loop.
Example: LoginStatus, PageLoad, or RetryCount.
Operator
Choose a logical comparison operator:
equal to (=) → Runs while a parameter equals a specific value.
not equal to (!=) → Runs while a parameter does not equal a specific value.
greater than (>) / less than (<) → Runs while the value meets the condition.
Example: RetryCount < 5 (loop will run while RetryCount is less than 5).
Parameter/Value
Set the value to be compared against.
Example: true (for a flag) or 5 (for a numeric condition).
Description
Provide a brief explanation of the loop's purpose.
Example: "Retry login until successful" or "Wait for page load."
Condition Logic (AND/OR)
Choose whether additional conditions should be combined using:
AND → The loop will continue only if all conditions are met.
OR → The loop will continue if any condition is met.
Example: LoginStatus != Success AND RetryCount < 5.
Example Use Case:
If you are waiting for a process to complete before proceeding, the parameters would be:
Parameter: ProcessStatus
Operator: not equal to
Value: Completed
Description: "Wait for process completion"
Condition: AND
Do-While Loop
The Do-While Loop ensures that the test steps execute at least once before checking the condition.
Example:
Navigating through multiple pages in a table until the required data appears.
Use Case Scenario: Automating a Login Attempt Until Success
Scenario: A tester needs to log in to an application, but the login process is unreliable. The test case should keep trying until login is successful or a timeout occurs.
Steps in SimplifyQA:
Use a While Loop to repeatedly attempt login.
Verify if the login is successful.
If not successful, retry the login attempt.
Exit the loop once the login succeeds or the maximum retries are reached.
Conclusion
Looping statements in SimplifyQA enhance automation by allowing repetitive execution of test steps efficiently. By using For Loops, While Loops, and Do-While Loops, testers can automate scenarios that require iteration and validation across multiple test runs.
Last updated