Loop over Dataset
abstract
Datasets allow running the same path with multiple sets of data. This is useful for:
- Data setup
- Verifying against calculations
info
Verifying against calculations:
Some test cases verify the state of an application. For example, can a product be created correctly, can it be edited, can it be searched, can it be deleted etc.
In these tests, the input just needs to be valid data. It does not matter what the specific value is. This can be accomplished using Data Generators.
However, in some flows, we may need to verify a calculation that is performed on a particular attribute. For example, we may want to check if a coupon discount is applied correctly to the cart total. To test this, we will need to set up the product price (say $100) and the discount value (say 10%) to known values so that the discounted cart total ($90 here) can be verified. Since these values are on different entities it is not possible to use data generators here. We need to explicitly specify the values via datasets.
However, in some flows, we may need to verify a calculation that is performed on a particular attribute. For example, we may want to check if a coupon discount is applied correctly to the cart total. To test this, we will need to set up the product price (say $100) and the discount value (say 10%) to known values so that the discounted cart total ($90 here) can be verified. Since these values are on different entities it is not possible to use data generators here. We need to explicitly specify the values via datasets.
Create Dataset
Dataset can be created in two ways:- From
Automate Dialog
- From
Node
From Automate Dialog
Let us create a simple Dataset.- Open the
Automate dialog
. - Navigate to the
Data
tab. - Click on the drop-down arrow for
Data Source
and selectCreate New
. - Set the
Data Source
name touser_details.csv
.info TheData Source
is where the data will be stored. Currently supports csv files.
A single Data Source can contain multiple Datasets. So all datasets pertaining to user may be clubbed into a single Data Source ofuser_details.csv
.
These files reside in<sahipro>/userdata/scripts/flowchartsdata/<project_name>/datasets
folder. - Enter a dataset identifier in the
Dataset
. (If not provided, it will bedefault
). - Choose the attribute from
Add Columns
drop-down. Eg.$user.firstname, $user.lastname
.infoWe need to provide values for these attributes.
For other attributes which are not specified in the dataset, data generators will be used. - Type the values for the attributes below the attribute names.
- Click on
Save
.
From Node
- On the
flowchart page
, right click on theNode
for which dataset needs to be created. - Click on
Data Loop
. - In the
Attach Datadet
dialog box, underData Dource
drop-down, selectCreate
. - The
Edit Dataset
dialog opens up. Enter the required data and save.

Run Dataset
Path Level
- On the
Automate
dialog, go toData
tab - Select the
Data Source
and aDataset
(group name) to associate it with the Path. - Select the dataset row to run by default when run from Automate dialog.
- Click on
Run
button onAutomate
dialog. - On the
Run Settings
dialog, select theRun Normal Path
and click onRun
button. - The flow executes one time and uses the select dataset row.
View Report
- Open the report by clicking on the
Reports
button/option either from theAutomate
dialog or from the flowcharts page. - The detailed report shows the execution with the used dataset row details.

Flowchart level/Project Level
- Click on
Run
button on the flowchart page or the project page. - On the
Run Settings
dialog, select theRun Normal Path
and click onRun
button. - The flow will be run multiple times to exercise each row of the dataset. For each row in the dataset, an individual target website browser will open and the steps will be carried out.
View Report
- Open the report by clicking on the
Reports
button/option. - The detailed report shows the multiple path execution with the used dataset row details.

Node level
- Lets take another example where the flowchart verifies the cart total for books purchase.
- The
Add $books
andVerify $cart total
keyword will be automated and extracted as follows:


- Click on
Add $books
andVerify $cart total
node and chooseData/Loop
from the menu. - Choose the Data Source and Dataset or Create a new one.
- Data source and dataset may be set from a variable as well.
- The keyword in the Node will be run in a loop over all rows of the dataset.




View Report
- Open the report by clicking on the
Reports
button/option. - The detailed report shows the multiple path execution with the used dataset row details. The keyword
Add $books
andVerify $cart total
has executed thrice.

Data / Loop Boundary
The start and end boundaries can be defined for the dataset attached to a node.The Keywords in the Nodes inside the start and end boundaries will be run in a loop over all rows of the dataset.
- Lets take the above example but split the keyword
Add $books
andVerify $cart total
into two nodes.- The
Add $books
andVerify $cart total
keywords will be automated and extracted individually as follows:
- Click on
Add $books
node and chooseData / Loop
from the menu to attach the datasetbooks.csv
with the node. - Click on
Add $books
node and chooseData / Loop Boundary
from the menu. ChooseStart
from the options to set the starting point of the data loop. - Click on
Verify $cart total
node, clickData / Loop Boundary
and selectEnd
to set the end of the data loop.
- When executed, the whole flow will be executed once but within that flow the set of nodes within the data loop boundary will be executed multiple times to exercise each row of the dataset.
View Report
- Open the report by clicking on the
Reports
button/option. - The detailed report shows the path execution with the used dataset row details. The keywords
Add $books
andVerify $cart total
both have executed three times.
info Note:- The selected row from a dataset will execute only in cases of Path run, Run Till Here and Run This.
- Flowchart level run and Project level run will use all the rows of the dataset irresepective of the selection of rows.
Data/Loop
andData/Loop Boundary
options will use all the rows of the dataset.- Flowchart level or Project level run will run the whole flow multiple time to exercise each row of the dataset. For each run, a new browser will open.
- You can change the dataset or click
Edit
to edit the dataset.
Environment based Datasets
Datasets can be overridden to use different data in different environments.
For example, to use different data for default, QA and production environments.
- Create a new dataset as shown here.
- Open the Edit Dataset dialog.
-
To create new environment, click on the drop-down near
Env
and selectAdd New.
- Enter the
env name
in the prompt. - This will clear the
Edit Dataset
dialog and a new folder with givenenv name
will be created underdatasets
folder of the project. - Enter the required data and save.
-
To create new environment, click on the drop-down near
-
To set the environment of execution, set
sahi_env
variable inExternal Variables
under Advanced Run Settings section ofRun Settings
dialog before running.
Data will be picked from data file of given environment instead of the default dataset.
info Note:- A dataset must exist in the default environment before it can be overridden in other environments.
- If the given environment does not have a dataset, data is picked up from the default dataset.
- The