MSBLOGS: QA Automation: What is Data Driven Framework in Automation?

Pages

Monday, April 18, 2016

QA Automation: What is Data Driven Framework in Automation?

Data Driven Framework:

In this Framework , while Test case logic resides in Test Scripts, the Test Data is separated and kept outside the Test Scripts.Test Data is read from the external files (Excel Files, Text Files, CSV Files, ODBC Sources, DAO Objects, ADO Objects) and are loaded into the variables inside the Test Script. Variables are used both for Input values and for Verification values. Test Scripts themselves are prepared either using Linear Scripting or Test Library Framework.

Demonstration of Data Driven Framework:
Creating multiple Google user accounts is the task we will try to accomplish using this framework.
In the example earlier, we hard coded the first name, last name, user id details etc. into our code while trying to create an account. We will have to separate the code from the data if we have to achieve data driving aspect for this script.
The data should come from a source that is not the program itself.
Typically the data input can be anything:
  1. MS Excel files
  2. Data base
  3. Text files
  4. XML files….etc.
Excel files are the ones that get used most often. The very fact that each action in QTP comes integrated with a data sheet of its own explains why that’s so.
You can use one or more data sources for a single script. The excel sheet that comes with the action can be used or you can use an external excel sheet too. Basically a data sheet can be any relevant external file.

For example:

This is the code that we need to data drive:
1. Browser("Gmail: Email from Google").Page("GoogleAccounts").WebEdit("FirstName").Set "ms"
2. Browser("Gmail: Email from Google").Page("Google Accounts").WebEdit("LastName").Set "v"
3. Browser("Gmail: Email from Google").Page("Google Accounts").WebEdit("GmailAddress").Set "DataTest"



After parameterizing the hardcoded values it will look like :

1.   Browser("Gmail: Email from Google").Page("Google Accounts").WebEdit("FirstName").Set DataTable("G_First_Name", dtGlobalSheet)
2.   Browser("Gmail: Email from Google").Page("Google Accounts").WebEdit("LastName").Set DataTable("G_Last_Name", dtGlobalSheet)
3.   Browser("Gmail: Email from Google").Page("Google Accounts").WebEdit("GmailAddress").Set DataTable("gmail_address", dtGlobalSheet)


Now the data can be kept in csv, xml or any other excel file.

Parameterization is a process for creating Data Driven Framework. As we can see in Data driven framework the data are kept separately from the script. Similarly we can also add the Output data we are verifying using the script.





No comments:

Post a Comment