Wednesday, July 18, 2007

Whats your Automation Framework?

I have seen an umpteen no of posts in every QTP group I visited asking about Test Automation frameworks. Here I would like to collate the useful inputs i received from various QTP groups and discussion forums.

The Keyword Driven framework consists of the basic components given below,

  1. Control File
  2. Test Case File
  3. Startup Script
  4. Driver Script
  5. Utility Script

1. Control File :

  • Consists details of all the Test scenarios to be automated.
  • User will be able to select a specific scenario to execute based on turning on or off a flag in the Control File.
  • Control File is in the form of an excel worksheet and contains columns for Scenario ID,Execute (Y/N),Object Repository Path, Test Case File Path.

2. Test Case File :

  • Contains the detailed steps to be carried out for the execution of a test cases.
  • It is also in the form of an excel sheet and contains columns for Keyword, Object Name, Parameter.

3. Startup Script :

  • The Starup script is utilised for the initialization and reads the control files.
  • It then calls the driver script to execute all the scenarios marked for execution in the control file.

4. Driver Script :

  • It Reads the Test Case files. Checks the keywords and calls the appropriate utility script functions based on specific keyword.
  • Error Handling is taken care of in the driver script.

5. Utility Scripts :

  • Perform generic tasks that can be used across applications. It should not be application dependent Advantage of Framework.

The main advantage of this framework is the low cost for maintenace. If there is change to any test case then only the Test Case File needs to be updated and the Driver Script and Startup script will remain the same.

No need to update the scripts in case of changes to the application.

QTP Framework

The framework requires the creation of Repository files, Recovery Files, Library Files (Reusable Functions or user defined functions), XLS files

1. Repository files are created Test manager or test lead or senior S/W engineer.
So we have to add or load or executes these repository files using within a script or using QTP tool.

2. After loading the repository file, then the library files are loaded dynamically into the scripts.
This library file contains functions & sub procedures & verification checks, reports.
Then these files are loaded dynamically into the test in two ways:
[a] before creation of library files we creates a functions(just record the functionality of the app and mention the function name at first and copy the script and paste into notepad and save as .vbs extension and save this a folder which we want to create at first and give the folder name as Re_Usable_Functions) .
Then if u want to make this file as reusable then go to Test tab and select Test settings-select Resource tab &click + button & browse the location of the VBScript® file which u stored in Re_Usable_Functions folder. Then this function is reusable you can use this file with that function name like: function ().
[b] loading library file at runtime u can use the statement-Execute File ("full path of the file which u stored in a folder").

3. XLS files-the functionality (data within a fields) of the app under test(AUT) is documented in a Data Table.
This Data Table contains test data for a particular screen fields and this data tables are loaded onto scripts manually.
Advantage:-so whenever the app data is changed, we don’t want to change the script just we have to change the data within the data table.
I am sending a script which contains how we develop datatable within a script.

4. Recovery Files-Recovery files are created using "Recovery Scenario Manager".
These files r used for an unexpected event or error occur within a run session and the recovery operation is necessary.
At first we understand the app functionality and we want to guess that what types of errors are occur during the script execution.
ex:-some times if there is misspelled data is entered within a field then a pop-up window will open and says "enter appropriate data ",so we want to create file for this using "Recovery Scenario Manager", in this 1]trigger event 2] Recovery Operation and 3] post recovery test run.
After this we enter with "scenario name” and save this in "Recovery_files" folder which we want to create at earlier stage like re_uasable_func folder.
Then select Test tab-Test Settings-Recovery tab and add recovery file which is saved in "Recovery_files" folder with scenario name.
Next execute this file whenever u want within a script using few functions like:
-declare a variable (ex-rep)
Variable = Recovery.GetScenarioPosition (Scenario File, Scenario Name)
Recovery.Set Scenario Status (variable, Status)
Status=True or False
Recovery.Activate
Then this file is executed whenever this particular error occurs.
and also use OnErrorResumeNext function also used. just got to built-in functions.

This is the one type of frame work. We called it as Master FrameWork or Action FrameWork. So if u needs any information regarding QTP framework and about QTP automation u just mail me.

Test Post

Test