For loops are used in all programming paradigms to ease the process of repeating actions. In order to be as powerful and feature-rich an alternative as a Scripted Testing Tool, Testsigma has included the provision to add for loops in the Test Steps. Let us demonstrate the steps with an example below:
You need to be familiar with basics of Test Case creation and Execution. Also, Familiarity with Test Step creation is expected. Check the following resources if you are new to Testsigma.
Also, basic knowledge about control flow statements such as for, while and their usage for the conditional flow of a program is beneficiary.
In this example, we will be going to Google Homepage and entering test data into Google Search box from an associated Test Data profile.
Creating Looping/repeating Test Steps
We can create a new Test Case or continue adding Test Steps to an existing Test Case. Let us quickly create a Test Case named 'For loop Demo TC'.
1. After creating a Test Case, click on Create Test Step button to add the first Step.
2. Create the pre-requisite Test Steps required before starting the For loop.
For our example, create a Test Step to navigate to the Google Homepage using the template Go to test data and replace test data with 'https://www.google.com'.
3. Now, let us start the For loop. Click on the Create Test Step again and select the For loop radio button. The Test Step creation wizard changes to a different one a shown below:
4. Make the following inputs:
Test Data Profile: Select the Test Data profile that you want to iterate over in the For loop.
We already have a Sample Test Data profile named 'Sample Data' that contains 6 rows of numbers from 1 to 6. We will be using that in this example.
Loop Start: Mention the serial number of Test Data set in the associated Test Data profile where the iteration is to start from.
Let us start from the first set. It is already selected and we don't need to make any change.
Loop End: Mention the serial number of Test Data set in the associated Test Data profile where the iteration is to end.
Let us go until the last set. Select the last set number from the list.
5. Now, create the For loop Test Step by clicking on Create and Continue button.
The For loop step has been added and we can continue adding Steps inside the For loop now.
In our example, we are going to insert a single step 'Type @|numbers| into Gsearchbox' to enter the data from Test Data Profile in the Google search box. This step will enter the numbers from Test Data Profile in the Google search box consecutively.
Note: There can be multiple Step Groups or If-Else statements inside the For loop.
6. Enter the above step and click on Create and Continue to add the Step and open the Create Test Step wizard for next Step. Repeat this until you have added all the steps required inside the For loop.
7. Finally, click on Create Test Step button at the bottom of the Test Steps to end the For loop and create the remaining normal Test Step.
That's all we need to get started with For loop Test Step Execution using Testsigma.
Happy Automation Testing!