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

Designing Keyword Driven Framework mapped at Operation Level – Part 1

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

In the previous article on Keyword Driven Framework, we covered the basics of the framework such as what Keyword Driven Framework actually is, what are the main components used in this framework, its generic flow and the common Keyword Driven Framework structures that are used most frequently.

We had seen that based upon how keywords are mapped in your framework, you can distinguish the framework in the following 2 ways –

  • Case 1: Keywords are mapped to the lowest level operation on an object (this operation usually is a single statement).
  • Case 2: Keywords are mapped to a function or action which contains a collection of statements.

Keyword Driven Framework Types


In this and the upcoming article, we will cover the first case in detail. We will see how you can create a keyword driven framework where most of the keywords are mapped to the operations at the object level.

Topics that will be covered in this article

  • 1) Components that are commonly used in this framework.
  • 2) The flow of the test cases in this framework.


Before we begin explaining each of the points mentioned above, let us first revisit the structure of this framework once again so that you get an idea about what framework is being referred to here.

Keyword Driven Framework where keywords are mapped to operations

From the above figure you can note that the screenshot shows the code (or flow) for the Login portion of GMail. And each of the keywords (like Set, Click, Sync shown in Column E) are mapped with the actual operations that you perform at the object level (like set value in a text field, clicking on a web button etc). This is the reason we are referring to this framework as the one where keywords are mapped to Operations.

Let us now jump over to the points that we intend to cover in this article.

Components that will be used in this Framework

Before we begin listing down the components that will be used in this framework, the important point you should note here is that in this type of framework you have to ‘first identify keywords and then later you have to map them with your functions’. The implementation of this concept can vary from person to person. So based on how you want to implement this concept, the components of the framework and the test case flow that you define might differ.

In the sample framework that we will create, we will cover the basic steps that would help you learn how to create a keyword driven framework. Let us now see the different components that are normally used with this Keyword Driven Framework. Side by side, we will also mention whether we will be using those components in our present framework or not.

  • 1) Excel Sheets to Store Test Case Flow: Normally, the flow of our test scripts (like open login page, enter user id and password, click on login button etc) are written in QTP Actions or Function Libraries. But for this framework, the flow of the test cases will be written in the excel sheets (as shown in the image in the previous section).

    And how you store the flows in the excel sheets would depend on you. For example, consider that you have 3 test cases – one for GMail, second one for Facebook and the last one for Yahoo Mail. To store these 3 test cases in the excel sheet, you can either create 1 excel workbook with 3 different sheets. Or you can also create 3 different workbooks each having a single sheet.Structure of Excel Sheet - Keyword Driven Framework

    One best practice that you can follow here is group the test cases based on their type. For example, suppose you have few test cases for GMail, few for Facebook and few for Yahoo Mail. So, you can create 3 excel workbooks each having multiple sheets. The first workbook will have all the GMail test cases in separate sheets, the second workbook will have all Facebook test cases and so on…Keyword Driven Framework - Test Case Sheet Format

    For our framework, we will create a single Excel Workbook which will store the test cases that we create for this framework.

  • 2) Function Library: In a Keyword Driven Framework, function library is the most important component. Its also the most complex component to design and script. This is because almost all the important things that your framework does will be scripted in the the function library only. Let us see some of the important things that a function library does in a Keyword Driven Framework.
    • a) First and foremost, function library will store the information about what all keywords are available in your framework and how they are mapped to different functions.
    • b) Function library contains the code which will read the keywords as and when they are encountered and  execute the functions associated with those keywords.
    • c) Also, when you write the flow of your test scripts in excel sheets, QTP will not be able to understand it because the flow is not in the syntax which QTP recognizes. So your function library will also contain the code which will read each line from the excel sheet and convert in into the format that QTP understands.

      Function Library Tasks - Keyword Driven Framework
      Because of all these reasons mentioned above, Function Library can be considered as the core component in the keyword driven framework.

  • 3) QTP Test Script (Driver Script): QTP Test Script (QTP Actions) is one more component that you use commonly in your automation frameworks. But the way the QTP test case (or action) is used in this framework is slightly different from the conventional sense.

    Normally, you will use QTP test cases in your framework to write the code (or flow) of the test cases that you want to automate. But in this framework, the test case flow is written in excel sheets. Also most of the important functionality and logic of your framework is written in the function library. Because of this, there is nothing much left that can be done from QTP test script.

    So in these situations, QTP test cases are used to just initiate the execution. QTP test cases will contain the code that will just call the function library. After this, the function library will take charge and execute the test cases. Because of this reason, QTP test case is also referred to as Driver Script (because the QTP test case (or action) just drives or initiates the execution).

  • 4) Excel Sheets to Store Test Case Data: To make your keyword driven framework more robust and to run the test cases against multiple sets of data, you can store the test data in separate excel sheets. When you store the data separately, you would need to write code in the function library which will fetch the data from the excel sheets. The image below shows how the test case excel sheet will look like if you store the data separately.
    Data Sheet Format - Keyword Driven Framework

    In order to keep things simple in our framework, we will not use a separate data sheet and will store the data together with the test case flow only.

  • 5) Object Repository: To identify and store the objects in this framework, you can either use Object Repository or use the Descriptive Programming approach in QTP. Based upon which method you use, you would need to write corresponding functions in your code to read and load the objects when the test cases are run. For this example, we will use the Descriptive Programming approach.


Flow of the Test Cases in this Framework

The below image shows the flow in which the test cases will be run in this framework.

1) The execution of the test cases would start from the QTP Test Case  (Driver Script).

2) When you run the QTP test case, it will load the function library and will pass the control to it.

3) Based upon the test case that needs to be run, the function library will load the corresponding excel sheet which contains the test case flow.

4) The function library will read each line from the excel sheet, convert it into a format that QTP recognizes and will then execute the line of code.

5) Once all the test cases are executed by the function library, the control will be passed back to the QTP Test Case and the execution will be stopped.

Keyword Driven Framework mapped at Operation Level Flow


This was all about the introduction to Keyword Driven Framework mapped at Operation Level. In the next article, we will cover, in detail, on how you can create this framework from scratch and write test cases in this framework.

Did you like this article? You can let us know your response 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 ×
  • Manoj Yadav

    Great Work Anish……very clear and simple explanation
    Thanks a lot

    • Anish10110

      Thank you Manoj.. Keep visiting.. 🙂

      • rukmini

        hi anish ur work is highly apriciated….keep continue to other test tools

  • Akash Rastogi

    Thanks a lot Anish for this Initiative…..I loved a lot these articles and is religiously following the update you write…waiting for the next article in this series…..

    • Anish10110

      Hi Akash.. Thanks a lot for the feedback.. :):) I have started working on the coding part and should be able to complete it in 2-3 days..

  • Pingback: QTP Framework Tutorials - Framework Types, Examples & Code Snippets - Automation Repository()

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

  • Nanda.D Reddy

    I am just wondering … why the people are more crazy about this keyword driven when there many simple ways to automate and maintain …. If we impliment this approach where do we have the validations … In my experience I never seen a keyword driven implimented in real time automation .. as it has got its own limitations .. Can we consider the keyword driven framework If the validations are very dynamic ( unfortunately almost all the applications have the dynamic validations). If answer Yes, Then how ?

    • Anish10110

      Absolutely Right… Pure keyword driven framework will rarely ever work on a real life application. I myself have never seen it implemented in the pure manner. It always is the hybrid approach that works best. This framework which works on keywords at operational level has many limitations. Infact each framework has certain limitations. That's why Hybrid Framework is important. One can pick up the best features from any framework and create a hybrid framework..

      What I feel is that many people are not aware about the exact workings of different types of frameworks. Once we see the framework closely and maybe work on it a bit, then we will have a clear idea about its plus and minus points. And this knowledge will surely help us come up with better approach for our future projects.

      What do you think about this?

      • Nanda.D Reddy

        Exactly .. I 100 % accept with your comments Anish .. I guess that awareness should come in everyone. As I have seen, Many people think the keyword framework is complex thing and it gives I solutions for all automation needs.But I really appreciate your hard work behind this .. and it would really help the learners to understand the different approaches of automation. Keep up good Job 🙂 🙂 .

        • Anish10110

          Thank You.. 🙂

  • ali

    excellent job , i love it , you are the great. take care , bye

  • Arun

    Hi Anish,

    Thanks a lot. This is one of the site which gives complete understanding of QTP for free 🙂

    • Anish10110

      🙂 🙂

      • ohh brilliant sir.I was looking for this kind information for last 1 year,finally got it.Thanks a lot sir.I challenge if anybody can get better articles then this on QTP

  • preeti

    PLEASE explain me HYBRID Framework i am just going mad trying to understand it totally cunfused and my trainer is not explaining it nicely…please HELP and no videos for hybrid..

    How to implement HYBRID Framework on say facebook login??????????????????????????
    Thanks

  • Prashanth

    Anish I had a lot of questions on how these frameworks create an impact and you have explained them really well…Thanks a ton!!!

    • Anish10110

      Thanks Prashant.. 🙂

  • Nrusingha

    Very interesting. You are truly a teacher who can make a way, show the way to his students.

  • SREENATH S M

    HI aneesh ,will you give the generic driver code which will fetch the keys from TestCaseFlowSheet.xls and make Execute cloumn ""YES"and the Status Column "PASSED".in .xls .with reference to keyworddriven framework mapped at functional level..to my id ellipsis047@gmail.com..

    regards
    sreenath

    • Hi Sreenath,

      Please have a look at the hybrid driven framework [final part] article. the logic that you are asking for has been implemented there..

  • rukmini

    hi

  • rukmini

    hi anish ur work is highly apriciated….keep continue to other test tools

  • Hariharan

    Hi Anish Thanks for the details. Just need a clarification on the above diagram. Is it good that the driver script interacts with excel sheet for test case flow or for data because in case if we want to change the data interface to SQL or XML instead of Excel we can just rework on driver script rather than touching the function library

  • Girija

    HI Anish…

    U have done a great job… Its really helpful. Now I am clear with types of frameworks. Thanks a lot for ur efforts and time….

  • Raja

    Super Bhayya … keep it up 🙂

  • Alex Makhalane

    Thanks for the article 🙂

  • Alex Makhalane

    Thanks. These articles are very clear.

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