KeyWord Driven Testing and Framework in QTP

Keyword-driven testing is a Software testing technique that separates much of the programming work from the actual test steps so that the test steps can be developed earlier and can often be maintained with only minor updates, even when the application or testing needs change significantly.

In case of keyword driven testing, we need to do proper planning and initial huge effort. Anyway it will give benefit of easy maintenance and easily adding more test cases/scenarios.

As we see the keyword view in QTP IDE, the keyword driven testing involves specifying the test steps in below format
Object  Action  parameter
Browser(“FireFox”).Page(“QualityPointHome”).webEdit(“username”).Set “QualityPoint”


->Browser(“FireFox”).Page(“QualityPointHome”).webEdit(“username”) is the Object.
->”Set” is the Action.
->”QualityPoint” is the parameter.

Here we can change any of the three things to create test steps.
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

a) Consists details of all the Test scenarios to be automated.
b) User will be able to select a specific scenario to execute based on
turning on or off a flag in the Control File.
c) 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

2. Test Case File
a) Contains the detailed steps to be carried out for the execution of a test
b) It is also in the form of an excel sheet and contains columns for
Keyword, Object Name, Parameter

3. Startup Script
a) The Startup script is utilised for the initialization and reads the control files.
b) It then calls the driver script to execute all the scenarios marked for execution in the control file.

4. Driver Script

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

5. Utility Scripts

a) Perform generic tasks that can be used across applications.

Advantage of keyword Driven Framework.

• The main advantage of this framework is the low cost for maintenance. 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.
The framework design will  be purely based on your requirements and your way of thinking. There is no Solid rule to follow.

Personally, I would like to have my own framework (hybrid framework) designed according to my own requirements.
Anyway, the best practice is, we should create below sub folders in your root folder.

ObjectRepository-> To keep your shared object repositories.
Datatables->To keep QTP data tables and external Excel sheets.
Config-> To keep environment variable xml file
RecoveryScenario ->To keep your recovery scenario files.
Tests-> You can keep your QTP Tests here. You may include Test containing Reusable Actions here. And a Test which is getting used as driver script can also be stored here.
library->you can keep your vbs file which contains vbscript functions.
Results-> You can store Result files (Either QTP result file or customized result file) here.
Actually there won’t be any solid rules/approach for creating QTP framework.

Leave a Reply