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
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
. - Select the
Data Source
andDataset
(group name) to associate it with the Path. This will also display the currently used dataset.
infoWhen running the flowchart, this path will be run withall rows of the Dataset. - Select the dataset row to run by default when run from Automate dialog.
info This row will be used only while interactively working on automation from the Automate dialog.
This selection is ignored when run from flowcharts level. - You can change the dataset or click
Edit
to edit the dataset
Run a Path with Single Dataset Row
- Click on
Run
button onAutomate
dialog. - On the
Run Settings
dialog, select theRun Normal Path
and click onRun
button. - The
OpenCart
website opens and the values automatically get populated for the user registration. Only the selected Dataset row is run. - Once the
Run
process is complete, the browser with OpenCart website closes automatically.
Run the Flowchart with all Dataset Rows
- Click on
Run
button on the top of the flowchart. - 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.
View Report
- Click on
Reports
button onAutomate
dialog. - The
Script Summary
is displayed.
-Click on thepath name
. - The
Suite Report
is displayed. The same path gets executed multiple times based on the data present in the dataset.
Here the path executed twice as there were two rows of data in the dataset.
Click on thePath name link
to view the script report. - The
Script Report
is displayed. - You can see all the details of running of each keyword along with the data used.
Dataset at Node level
Datasets can also be attached to a Node.- Click on any Node and choose
Data/Loop
from the menu. - Choose the Data Source and Dataset or Create a new one.