How to Use Data Driver for Automated Parameterization in UFT

The Data Driver in UFT provides you an option to quickly parameterize required property (or all) values of test objects, checkpoints, and/or method arguments containing the same constant value within a given action. You can record a Test and quickly parameterize constant/hard-coded values with either DataTale, Environment Variable, or a Random number.

In this article, I discuss the following items:
  • How UFT Data Driver works
  • Replace a constant value using a parameter
  • Replace all occurrences of constant value with a parameter

How Data Driver works in UFT

Let’s suppose we have recorded a Test on Mercury Tour Demo application and the following is the recorded code. You can see the constant / hard-coded values in the script highlighted with yellow color.

In real-life automation projects, there is no room for hard-coded values and everything should be parameterized to test the same test script with different sets of data.

In order to replace constant values with parameters, go to “Tools > Data Driver”.UFT takes some time to scan the entire test for constant values before opening the Data Driver utility. When the Data Driver opens, it displays the list of default constant values in the current action. The constant column indicates how many times the constant value has been used in the action. The parameterized column indicates the number of occurrences the constant value has been parameterized.

uft data driver

The Data Driver does not show the Test Object name of the script as constant values. If you want to parameterize a Test Object as well or any other value that is not being displayed in the list, click on the Add Value button. The “Add Value” dialog box will open. Enter a constant value in the dialog box and click on the OK button. The constant will be added to the list.DataDriver UFT

Replace a Constant value Using a Parameter

Select the constant value and Click on the Parameterize button.
UFT-data-driver-9753
The data Driver wizard will be displayed with the default selection “Step-by-step parameterization”.
DataDriver-UFT-098879
Click on the Next button. It opens the “Parameterize the Selected Step” window. It also defines the name of the parameter. You can use the same or manually change it and click on the Next button. I have updated the parameter name to “Airlines”.
UFT data driver Wizard
The constant value will be parameterized. Click on the Finish button.

The Data Driver window will be displayed. You will notice that the constant column will now be showing 0 and the Parameterized column will be showing 1 value against the selected constant value indicating it has been parameterized. Click on the OK button.

UFT-data-driver-After

The constant value will be replaced with the parameterization statement in the code and the parameter name along with the value will be added in the DataTable.

uft datatable

Replace all occurrences of constant value with a parameter

The Data Driver utility gives you an option to replace all occurrences of constant values with a parameter. In the following code value “2” has been used in three different web list-objects.

If you open the Data Driver it will look like the following snapshot. There are three occurrences of constant value 2 and the number of Parameterized constant value will be 0.

DataDriver-UFT-8784

Click on the Parameterized button. Data Driver Wizard will be displayed. Select the “Parameterize all” option to parameterize all occurrences of constant value “2”.Data Driver automatically assigns the name of the parameter.

DataDriver-UFT-7235

The name might not be very meaningful. So I would recommend it to give a meaningful name. To edit the parameter name, click on the pencil icon. The parameter Options window will be displayed. Provide a meaningful name and click on the “OK” button.

DataDriver-UFT-0975

Data Driver Wizard will be displayed again. Click on the “Finish” button.

DataDriver-UFT-8763

The Data Driver window will be displayed and the “Parameterized” column will show that 3 occurrences of constant value “2” have been parameterized and the number of constant will become 0.

DataDriver-UFT-8763-1

Click on the OK button. All the constant values will be replaced with the same DataTable parameter.

Recommended Posts

Leave a Reply