Keyword Driven Framework in QTP

There are various types of frameworks that a user can use in QTP and Keyword Driven Framework is a commonly used framework type among these. The different types of framework that are available in QTP are –

  1. Linear Framework
  2. Modular Framework or Functional Decomposition Framework
  3. Data Driven Framework
  4. Keyword Driven Framework
  5. Hybrid Framework
  6. BPT Framework or Business Process Testing Framework

In this article, we will cover the basics of Keyword Driven Framework.

As the name suggests, Keyword Driven Framework is a framework which involves the use of Keywords. This can be better understood with the help of an example. Consider an example where you have automate a test script that does the following things –

  1. Login to Facebook.
  2. Count the number of messages you received.
  3. Logout from Facebook.

Now if you want to write a script for this test case using pure functional decomposition approach, you will need to create 3 different functions, each of them will take care of login, counting messages, and logout part.

This is what you will do in normal functional decomposition approach. For keyword driven approach, you have to go one step further. You have to find out some keywords for each of these flows and then associate these keywords with the functions that you have created. (A keyword is any text that has some meaningful name).

For example, let us consider that you have created the following 3 functions – fnLogin, fnCountMessages and fnLogout. Now let us identify some keywords for the flows. The keywords can be – Facebook_Login, Count_Messages, Facebook_Logout.

Now what you have to do is associate the keywords with the functions. This can be done in the following way-

  1. Save all the keywords in an excel sheet.
  2. Save all the functions in a function library.
  3. Create a test script associate the function library to this test case.
  4. Now you would have to write some code that will read the keyword from the excel sheet and then call the corresponding function from the function library. The association between the two entities can be achieved through select case statement.
  5. This way you can create a basic keyword driven framework for your test scripts.

Flow of a Keyword Driven Framework

The typical flow of a keyword driven framework is as follows –

1)      When you run the test script in QTP, it will first call the driver function from the function library which has the logic to read keywords from excel sheet.

2)      This driver function reads the keyword from the excel sheet.

3)      The function then identifies the action that is associated with this keyword.

4)      The driver function will then call this function which will do the required operations on the application under test.

5)      Once the function has completed execution, the control moves back to the driver function.

6)      The driver function reads the next keyword and the flow continues till all the keywords are read.

For complete set of articles you can visit QTP Framework page. You can also visit QTP Tutorials page for more tutorials on QTP.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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