The general steps involved in the data driven framework are:
In this tutorial, we will develop a data driven framework for a sample test case by using Excel as an external source for the Test data.
Test Case: Open the order number and get the customer name for that order. Repeat the same process for different Order numbers
External Source: Excel File
The External source for this sample is an Excel file. The VB script in QTP must be written to open an Excel file in order to read the test data. This can be achieved in a hierarchical manner.
1. An excel file is first opened an as Application
2. Then the workbook must be opened from the specified location
3. The sheet where the test data are present.
4. Finally the cell must be read.
Once the Test case is ready, start adding all the required objects to the repository. In our test case, the objects need to be added are as follows
“Order No” Checkbox which can be obtained when the “Open Folder” icon is clicked
The WinEdit box of the Order no (where the numbers are entered)
The OK button
The “Name” field which is a WinEdit box. This field will be populated with a name once the OK button is clicked for a particular Order number.
Before running the script, ensure that the excel file containing the test data has been saved and is closed.
Below script is to read the order number from the excel and assign it into the application through variable “vOrder” and write the customer name from the application through variable “vName”.
Excel Name: FlightDDF.xlsx
Sheet Name: Sheet1
The Data Driven Framework can also be developed by writing descriptive programming.