site
stats
By Anish Pillai Anish Pillai Posted under QTP Concepts | QTP Framework

QTP Keyword Driven Framework – Part 1

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×

Till now we have covered QTP Linear Framework, Modular Framework and Data Driven Framework as part of the QTP Framework series of articles. Beginning with this article, we will cover the various aspects of QTP Keyword Driven Framework in detail. We will be covering all these details together with examples and downloadable code in 4 to 5 articles.

What will you read in this article

In this article, you will read the following topis that will help you understand the basic concepts of Keyword Driven Framework.

  • 1) What is Keyword Driven Framework?
  • 2) The main components that are part of almost all the Keyword Driven Frameworks.
  • 3) Generic flow of a Keyword Driven Framework.
  • 4) Some commonly used Keyword Driven Framework structures – Screenshots.


What is Keyword Driven Framework?

Keyword Driven Framework is a type of QTP Framework where for a particular test case, you would first identify a set of Keywords and then associate an action (or function) which each of these keywords.

Let us understand this concept with the help of an example. Let us consider that you have to automate a flow where you would need to do the following things in GMail.

  • 1) Login to GMail.
  • 2) Count the number of unread emails in Inbox.
  • 3) Logout from GMail.


Now, let’s see how we can approach this test case from Keyword Driven Framework perspective. If you look at the above test case from pure Modular Framework point of view, you will be able to easily identify that you would need to write 3 different functions for the above test case. These 3 functions will be used to – Login to Gmail, count unread emails and logout.

Once you have identified the functions, the next step is to identify some keywords and then associate the functions with these keywords. Below figure shows a pictorial representation of this concept.

Keyword Driven Framework - Identifying Keywords

From the above image you can see that basically a Keyword Driven Framework is nothing but a collection of keywords & functions (or actions or operations) and the association between these two entities. So to create a keyword driven framework, all you have to do is –

  • a) identify keywords and store them somewhere,
  • b) create functions for the business flows, and
  • c) associate these functions with the keywords.


Common Components and Workflow of a Keyword Driven Framework

The major difference between the Keyword Driven Framework and others is the use of “Keywords”. Most of the other things remain the same. You need to identify the keyword and store them somewhere.

Below is the list of common components that you will find in most of the keyword driven frameworks.

1) Excel Sheet to Store the Keywords: This is the only extra component that you will find in a Keyword Driven Framework. Once you have identified the required keywords, you can store them in an excel sheet. You would need to write some code that will first open this excel sheet and copy the keywords. Based on the keyword, QTP will call the function associated with it.

2) Function Library: In Keyword Driven Framework, function libraries usually play a very important role. You would have to built all the necessary intelligence in the function library so that it can read the excel sheets and call the different functions based on the Keywords.

3) Data Sheets: As with the other frameworks, you can use the data sheets to store the test data that will be used in the application.

4) Object Repository: Based on the design of your Keyword Driven Framework, you can either use an object repository or completely skip it (if you are using Descriptive Programming approach).

5) Test Scripts: Again based on the design of your framework, you can have separate test scripts for each manual test case or a single driver script that will execute all the test cases. (This will be covered in detail in the upcoming articles).

The below image shows the generic workflow of Keyword Driven Framework.

Keyword Driven Framework - Generic Flow

From the above figure, you can see that the generic flow of a Keyword Driven Framework is something like this –

1) Test Script or Driven Script calls the main function library. This function library contains the code that reads the keywords from the excel sheet.

2) The function library opens the excel sheet and reads the first keyword associated with the test case.

3) The function library calls the function associated with this keyword.

4) The function then performs all the required actions on the application that is being tested.

5) Control returns back to main function (in Step 2) which then reads the next keyword. Steps 2 to 5 are repeated till all the keywords associated with a particular test case are called.

Some commonly used Keyword Driven Framework Structures

As mentioned in the beginning of the article, the basic premise of a Keyword Driven Framework is that – you identify some keywords and write associated functions. This generic statement provides you with a lot of scope to improvise and put in your own thoughts to build this framework.

That’s the reason why, if you search for Keyword Driven Frameworks on the internet, you would find a variety of ways in which people have implemented this idea.

Based on the usage of Keywords, you can broadly classify the framework in 2 different types –

1) Frameworks where Keywords are associated with entire functions. Here, the functions are a collection of different operations or steps. (like Login function, which is a collection of multiple steps). So when you associate a keyword with the function, it means that a single keyword is associated with a collection of steps.

2) Frameworks where Keywords are associated with the lowest level operation on an object. Here, the lowest level operation is the operation that you perform on an object. Like click operation on button, set or type operation on a text box. So the keywords that you will use in this case would be Set, Click, Type etc which will be associated with functions which will just click on the object or enter value in a text box. In other words, the function associated with this keyword will do only 1 thing.

Let us understand the above two points with the help of examples. We will use the following 3 test cases as an example –

  • 1) TC_01: Login to GMail, find how many emails you received today and then logout.
  • 2) TC_02: Login to GMail, send an email to one of your contacts and then logout.
  • 3) TC_03: Login to Facebook, find how many notifications you have and then logout.


Frameworks where Keywords are associated with entire functions

Example 1: This is one of the most common formats of Keyword Driven Frameworks that you will see around (with slight variations here and there). Here, you need to specify all the keywords against a test case. For ease of understanding, you would also need to provide a description for each of the keywords. The below image shows how the keyword excel sheet would look like.

Keyword Driven Framework Design - Flow 1

Example 2: This is another common structure that is used very frequently and is quite similar to the previous one. The only difference is that the keyword names are self explanatory and hence you don’t need to provide the description for each keyword. The keywords can be arranged horizontally or vertically as per your wish. The below image shows the structure of the keyword excel sheet with horizontally aligned keywords.

Keyword Driven Framework - Flow 2

Frameworks where Keywords are associated with the lowest level operation on an object

Example: As mentioned previously also, in this type of Keyword Driven Framework design, the keyword is associated with a small operation (like click button, set value in some text box) rather than associating it with an entire function (like login, logout etc). Also this is a framework design that is quite complex and used rarely. Image below shows the screenshot of Login component of GMail.

Keyword Driven Framework - Flow 3

In the above example, Set, Click and Sync are the keywords that will be associated with corresponding set, click and sync functions provided by QTP. All other functions will also be written in the same way in this framework design.


This was all about the basics of Keyword Driven Framework. We would be covering each of the above mentioned examples in detail (together with downloadable code) in upcoming articles.

Would you like to share any other Keyword Driven Framework format that that we might have missed here? Let us know your views about this article using the comments section.

If you enjoyed this article, you can join our blog to get new articles delivered directly in your inbox.

Visit QTP Frameworks Main Page for more articles on QTP Frameworks. You can also visit our QTP Tutorials page for more QTP Tutorials.

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×
  • Pingback: QTP Framework Tutorials - Framework Types, Examples & Code Snippets - Automation Repository()

  • balaji

    Hi Anish,

    I am the regular follower of all your articles.Your articles on framework was excellent and it was one th best articles which i read.your articles made me to create my own customized framework in my work.

    • Anish10110

      Hi Balaji,

      That's really really cool.. :):) What all components and features have you implemented in your framework design?

      • balaji

        Hi Anish,

        I have created an simple framework which has seperate folder for each component such as or,results,function library,script ,datatable and i used the data driven framework-2 with some customization.currently am working on creating batch execution model to incorporate in it.

        The article on broken link validation was very useful..thanks a lot for providing very useful info on ur website:)

        • Anish10110

          That's Cool.. 🙂 :)..

          Having a proper folder structure as you have defined is one of the best practices and helps a long way in coming up with a good framework design.. :).. Please continue with it and share the details with us.. 🙂

  • vins

    Hi, It looks cool.
    How do you control the logical events in the Pure keyword driven framework (with lowest level operations)?
    Say..
    If this control appears do this otherwise do that. Something like this.

    • Anish10110

      Hi Vins,

      For that we would be writing the some custom functions that will do the desired operations. It would not be possible to write functions that will work at the lowest level. There will be few custom functions that will have a set of operations.

      • vins

        Yeah..got it.

        • balaji

          Hi Anish,

          when the second part of keyword framework will be availabe waiting for it..

  • balaji

    Hi anish,

    When the 2nd part will be available.waiting for it.

  • Rupali

    Good Work, great articles on framework… appreciate your efforts Anish….waiting for keyword driven framework code…Thanks

  • Naresh

    Awesome work……waiting for keyword driven framework code

  • Ankesh

    Hi ,

    I have a query. Once you identify the keyword from the data table then you call the corresponding function for that keyword. My question is if function for corresponding keyword is also mentioned in the sheet then how can we call that function in the script? What will the code for that?

    swfwindow(button).( I need say call loging function which is in correspondence of the button keyword). What should be the code to call it?

    Ankesh

    • Anish10110

      Hi Ankesh,

      This is usually done using Select Case statement. For example:

      Select Case keywrd

      Case "Login" fnLogin()
      Case "Logout" fnLogout()

      End Select

      This way you can map the functions with the keyword. And even if the keyword name and the function name would match, it would not create any issue.

  • Pingback: Designing Keyword Driven Framework mapped at Operation Level – Part 1 - Automation Repository - Automation Repository()

  • mukesh

    Sir i am m.tech student. can you please tell me ..how this keword framework is beneficial in reducing efforts / costs in with mathematical proof . i will be vey thank ful to you if you colud mail me this on my mail at — Mukesh 311a@gmail.com .

    • Venkatesh.d

      We are using Keyword driven framework for our Project.
      here we use seperate 'Keyword' for each function and the functions defined in Lib File are Very generic and can be run on different Web Pages of an Apps.
      Instead of using alias Name(keyword we can use Function Name Directly )

      • Anish10110

        Well Yes. That is also a way it can be done. And where are you defining the keywords? Excel sheets? or some other way? Also how is the mapping being done in your framework??

  • Pingback: Desigining Keyword Driven Framework mapped at Functional Level – Part 1 - Automation Repository - Automation Repository()

  • Aruna

    Hi Anish, In the above artical you have mentioned "Test Scripts: Again based on the design of your framework, you can have separate test scripts for each manual test case or a single driver script that will execute all the test cases. (This will be covered in detail in the upcoming articles)."

    CAN u plz me know where this artical is covered?

    • Anish10110

      Hi Aruna,

      I planned to cover this in Hybrid Driven Framework articles.

  • Pingback: complete real time scripts of qtp « TESTING HUB()

  • Lovesh Jain

    Hi Anish,

    Great Work.. It is really a very helpful article

  • Badri

    Hi,
    I have no automation background. I am starting a test automation project using QTP. I am searching on internet for a best approach and come across your framwork concept. But i have some basic questions. Can i use/implement you framework directly without writing any own functions? If yes, where can i downlod the code of your framwork? If i use your framework, i guess i dont need to record scripts in QTP? Sorry these are basic questions, but i am completely new to framwork concept. please advise.

  • Susan

    I am using qtp 11 and trying to create a keyword driven framework where I have parameterized my logins. I am running into issues where only the first row is run only. I tried contacting HP as I had heard other people running into the same issue but they were not any help. Do you have any suggestions? If I use 1 login/pw only hard coded into a login function the script runs fine. I however need to test with many users. Any suggestions would be most helpful. Thanks.

  • Pankaj

    Hi Anish,

    The framework example you have given is excellent. I am trying to implement the same in our project and needed some guidance from you if not much of an inconvenience: how to arrange the folder structure for the test cases? I mean what is the optimum way to organize the folders for the various test suites in a project?

    Warm Regards,

    Pankaj

  • Pankaj

    Hi Anish,

    The guidance you have given with regards to the frameworks is invaluable. I am trying to implement the keyword driven framework in my project and am starting from stratch; can you give me a general idea of the folder structure that needs to be implemented in regards to the test suites: what considerations need to be taken care of to get the optimum results?

    Thanks for this excellent website.

    Pankaj

  • Nrusingha

    Very nice explanation.
    Totally clear-cut vision
    Only QTP frustrated me.
    But I got more Ideas, even I already worked more than 3 year in a key word driven framework.

  • Pingback: Important Links Related to Selenium()

  • Preeti

    Awesome explaination…tried searching many articles to get the clear picture and this is THAT ONLY ONE article that came as relief !!

  • venugopal

    HI SUSAN,

    Try by using the below code at the end of ur script DataTable.SetNextRow

  • Hemalatha

    hi, Is it necessary to know VBscripting language to learn QTP

  • syed

    Excellent and Brilliant explanation, even beginners can understand clearly. keep it up with your service to the society

  • Bey Melamed

    Great job, great post(s).
    I have implemented something similar using Java / Selenium WebDriver and found the following very useful:
    1) The ability to set variables (either hard coded or from web elements)
    2) A description column that is used for reporting purposes.
    3) The ability to use variables (e.g. {username}) in ALL parts of the paradigm (reporting, validations, etc.)
    4) Incorporate os commands (fileCopy, batch / scripts, etc.) for purposes of setting up the test environment.
    5) The ability to 'call' existing tests / scripts (e.g. another worksheet.
    With these features implemented you get re-use and modularity on steroids.

  • Ekona Pikin

    Sir Anish,I want to really say Great! ,and awesome job,I recently started learning QTP and have way heard some of these topics you are teaching herein ,-however your lesson have tremendously helped me cement what I have picked
    you are awesome sir Anish

  • Alex Makhalane

    Yet another great article!! 🙂

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×