QTP Framework Basics

Let us assume that you are asked to create test scripts for an application. As a test engineer, what would be the basic things you want to accomplish? The most important expectation is that the test script should do the intended work. Other than that wouldn’t you want that your code is easy to understand, can be re-used, needs little maintenance and is scalable? All these are the additional features which if you have, makes your life much much easier. And how do you achieve all these things? Well, this can be done by using a good Automation Framework.


a) The bottom of this article has links to different QTP Frameworks.

b) All articles on QTP Test Automation Framework contain a download link at the bottom of the article, from where you can download the sample scripts and use it as required.

What is a QTP Framework?

QTP Framework, or in general a Test Automation Framework, is nothing but a set of guidelines which you can follow during scripting to achieve the above mentioned “desired” results. These set of guidelines can be anything such as –

  • – coding standards like the variables names should begin with the type of variable (eg. intNum, strMsg, arrArray), function names should start with fn (eg. fnCalculateSum).
  • – structure of your data sheets, how your workbooks and the individual sheets in them are grouped.
  • – what folder structure is required to be followed to save the test scripts, reusable libraries, object repositories, test run results.
  • – how should test results be stored and displayed.
  • – how different team mates can access that shared repositories, libraries and how they should update these.
  • – and many more…

Following these guidelines would lead to the job being done in a consistent manner which would ultimately result in a framework which will provide you with all the benefits that you had aimed for.

Please note that these are just a set of guidelines and not rules which are compulsory. Even if you don’t follow these guidelines, you would be able to achieve your most important task i.e. running the scripts to see if the application is working fine or not. The only thing is that you might end up spending a lot of effort scripting (if there is no code re-use) and maintenance would turn out to be a tough nut to crack.

Salient Features of a Test Automation Framework

Following are the features that should be available in a good automation framework.

  • a) The framework should be created in such a way that it helps achieve maximum possible re-use.
  • b) The test scripts should be easy to understand and maintain.
  • c) The framework should be designed in such a way that all different components such as test cases, function libraries, object repositories, data sheets, configuration files and test results are stored in separate folders. This would help the users understand the framework quickly.
  • d) Data parameterization should be done to keep the code separate from data, so that the same code can be re-used for different sets of data.
  • e) Run Results should make sense and should be easy to understand. You can also provide high level and detailed test results separately.
  • f) Proper error handling techniques should be used. You can also providing screenshots of the failed test cases.
  • g) When test cases are run in batch mode, failure of 1 test case shouldn’t affect the execution of the remaining test scripts in the batch.
  • h) You can also write QTP AOM code in VBScript which can act as the starting point for the execution of test cases.
  • i) The framework may also include email (and if required SMS) functionality so that the test results are automatically mailed/sms’ed to the stakeholders.

Other than these features, you can also include various other features based on your requirements.

Frameworks used in QTP

Following are the different types of QTP Frameworks that you can use while creating test scripts. (Click on the links below for detailed articles on each of these QTP frameworks)

1) Linear Framework in QTP – This is the most basic framework where you write your script as is. That is, with this approach you write all the steps one after the other in a step by step manner.
2) Modular Framework in QTP – In this framework, you write the entire code into different functions and then you call these functions as and when required. These functions can be both reusable and non-reusable.
3) QTP Data Driven Framework – Here, your data is kept separate from the code, preferable in excel workbooks. This helps you execute the same code for multiple sets of data.
4) Keyword Driven Framework in QTP – In this type of QTP Framework, you can create different keywords and associate different actions with these keywords. When QTP encounters a particular framework, it will execute the action associated with that framework.
5) QTP Hybrid Framework – Hybrid framework is a combination of one or more frameworks discussed above. Based upon your requirements, you can combine the features of any of the above frameworks. The resultant framework would be a Hybrid framework.
6) BPT Framework in QTP – In this QTP Framework, you can divide your test case flow into multiple Business Components. You can then re-use these components as many times as required. You need Quality Center access in order to use BPT Framework. Also you need to acquire BPT license from HP in order to use this framework.

For more QTP tutorials, please visit QTP Tutorials page in AutomationRepository.com

This entry was posted in QTP Frameworks. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s