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 –
- Linear Framework
- Modular Framework or Functional Decomposition Framework
- Data Driven Framework
- Keyword Driven Framework
- Hybrid Framework
- 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 –
- Login to Facebook.
- Count the number of messages you received.
- 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-
- Save all the keywords in an excel sheet.
- Save all the functions in a function library.
- Create a test script associate the function library to this test case.
- 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.
- 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.