In the previous article on Keyword Driven Framework mapped at Operation Level, we covered the basic features of the UFT keyword driven framework that we would be creating here.
3) A function library will be created which will contain the code to read the lines from excel and convert in into QTP recognizable format. Before beginning with the framework creation part, the first step would be to identify the test cases that you want to automate. 1) TC_01_CreateOrder: For this test case, we will write the script that will login to Mercury Flight Reservation system and then create a new flight reservation. 2) TC_02_ModifyOrder: In this test case, the script will log in to the application, open an existing order and then modify the order. 3) TC_03_DeleteOrder: Here, the script will again log in to the application, open an existing order and then delete the order.
Step 1-A: The first step would be to define the format of the excel sheet that will be used to store the flow of the test cases. To create the excel sheet format that we will be using here, open an excel sheet and add the values as shown in the below figure. Parent [Column A] – This column will contain the hierarchy of all the objects until the actual control on which you want to perform some operation. PProperty [Column B] – This column will contain the properties of the objects that were added in Column A. Control [Column C] – Column C will contain the name of the control on which you want to perform the operation. CProperty [Column D] – Column D will contain the property that is associated with the object in Column C. Action [Column E] – This column stores the name of the action that needs to be performed on the object. Data [Column F] – In this column, you will be providing the data that goes with the action. The below image shows how the flow will look in excel sheet for the sample sheet covered here. NOTE 1: There would be certain cases where you would need to perform operation on the parent object only. NOTE 2: There will also be certain cases where the operation would not be performed on any object. Step 1-C: Since you have understood the structure of the test case flow excel sheet, we can now start writing the flow of the test case in the excel sheet.
3) Now whatever actions we have to perform in the application, we have to capture it in the excel sheet. 5) Have a look at the properties of both the controls and select the ones that you think will uniquely identify both the objects. NOTE 3: If you are not comfortable with this process of identifying the properties using Object Spy, you can follow an alternate method where you can first record the scenario in QTP. 6) Once you have added the values for Agent Name field in the excel sheet, you can follow the same process to add the values for entering values for password field and OK button.
Since we have written the flow of the login portion in the excel sheet, we can leave it at this step for the time being and start concentrating on the next part which is – writing code or functions in the function library that will read the excel and convert it into QTP readable format. Before writing the functions, make sure that you create a function library and associate it with your QTP Test Case.
2) The below function converts values from columns A and B of the excel sheet into QTP readable format. 4) The below function performs Actions or Operations on the object which is retrieved from the previous function. The good part of this framework and the function library is that you would need to work more on the functions and the code in the initial part only (when you are beginning to develop the framework). As an example, you can see that the functions SetValue, Click etc are already written in the function library. Once we have written the basic functions for running the script from excel sheets, we need to combine everything together and run the code to see if it works. The entire sample framework together with the function library and flow for all the 3 test cases is available in the sample framework. Have you read this article and tried to work on the sample keyword driven framework attached here? Since this is a basic framework created to just help you understand the basics, there are many things which are not covered as part of this framework.
Improvement 1) You would have noticed here that the test case flow in excel sheets is not modularized. If you enjoyed this article, you can join our blog to get new articles delivered directly in your inbox.
Hi Anish, I realised that while executing scripts sometimes QTP needs more than one property to identify the Objects.
As an alternative, you can also try one more method where you can specify all the values in the same columns with some additional delimiters. Can you please elaborate the method you have used and the error message that you are getting while implementing the solution??
I have been doing some sort of keyword driven testing for a while now but have not yet worked with QTP. What a mighty good job you have done by showing 'realistic industry oreinted example of how a framework is used. I was wondering how do people make functions reusable as each of my function always contained some object from object heriarchy and I didn't know when will I create a code that will only contain vbscript. Now I realize how code can be resuable, reusable code favors some frameworks more than others. Hi Anish, Its very fruitful read for those as well who has already worked on frameworks, amazing way of explaining frameworks. Anish, Can you suggest if you have written something on how we should take our QTP results in other than excel format? If you like reading Automation Repository, you can subscribe to this blog so that all the new articles get delivered directly in your Inbox. A blog on QTP, Automation Repository aims to provide information rich articles to help you learn various concepts & resolve your doubts on QTP. 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. 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. 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. From the above figure you can note that the screenshot shows the code (or flow) for the Login portion of GMail.

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. 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.
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. 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. 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. 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. 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.
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. Absolutely Right… Pure keyword driven framework will rarely ever work on a real life application.
What I feel is that many people are not aware about the exact workings of different types of frameworks. Anish I had a lot of questions on how these frameworks create an impact and you have explained them really well…Thanks a ton!!! QTP - Designing Framework - Learn what is QTP QuickTest Professional and associated concepts like Record and Play Back, Master Driver Script. Generally in Keyword Driven Framework Driver Script is the only QTP Script, remaining all are Vb Script files .
DRIVER SCRIPT initialize qtp to run Main Script file in framwork is called a driver, where you are colling the all the function or action. Sample of Driver script to run multiple QTP scripts Hi, If you just wish to control the execution of QTP Actions, you don t need anything special. The article contained information about the components that can be used in this framework as well as the general flow of the test cases. All these 3 test cases will be based on Mercury Flight Reservation application (windows based application). This action or operation will be the keyword that will be mapped to some appropriate operation in the function library. For example, for Set action, we will need to provide the data that will be entered in that particular field.
Since we will be working on a windows based application, you can deselect the Web Add-in from Add-in Manager at start-up.
As an example, we will just work on the login portion of the application where we will enter Agent Name, the Password and then we will click on OK button. Add the objects and the properties in the excel sheet in the 2nd row (just below the header). Then you can go to local Object Repository and select the values that have been used by QTP.
Once you are done with all these steps, you would have an excel sheet that would look similar to the image below (the properties of the objects may change based upon what values you have selected to use). The idea here is that we will create the necessary functions and then run the script for the 5-6 lines you have written in the excel sheet. Later, it combines values in Cells A, B, C and D to form one complete object on which the action will be performed.
Once you have a look at the entire framework, you will get a fairly good idea about the functions and how they interact with each other. As and when you add new code in the function library, you will be able to reuse it for similar type of objects and hence the time taken to write the later test cases will be greatly reduced.
Now, if you want to use these functions for any other text box, button or link, you would just need to call the keyword in the excel sheet. To combine everything together, you need to create a proper framework with the folder structure, save the function library and the excel sheet in appropriate locations. This function is nothing but a wrapper function which gives a call to fnReadExcel() function. Once you have verified that the code is running fine, you can then keep on adding the flow in the excel sheet and add corresponding keywords in the function library. You can download this framework (link available near the bottom of the article) and play around with the code. I would list down the points here and you can try to modify the framework by incorporating these changes. For example, all the 3 test cases contain the flow of the login part (which means that login code is repeated in all the 3 test cases). Because of this, if you want to run the flow for multiple data, you would need to change the data values before each run. If you have any points to add here, or if you have any other improvement which can be added in this framework, please let us know about it using the comments section.
In this case we can Add one more column Property Name, so that we can mention more than one Unique properties and their corresponding Values into the CProperty column. And if you want to run multiple iterations, you can use a for loop so that the function picks up the data from different rows. I have started coding QTP in data-driven framework, something I only got to know after reading your blog. Mine was data-driven, so I think it doesn't suit it as much as it favours keyword-driven. This blog aims to provide information rich articles to help you learn various concepts in QTP. 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. 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).

Let us now see the different components that are normally used with this Keyword Driven Framework.
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).
For example, consider that you have 3 test cases – one for GMail, second one for Facebook and the last one for Yahoo Mail.
For example, suppose you have few test cases for GMail, few for Facebook and few for Yahoo Mail. 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. But the way the QTP test case (or action) is used in this framework is slightly different from the conventional sense. 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. 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. 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. 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.
In this article, we will actually implement all this and come up with a basic keyword driven framework.
In this case, you just need to click on the button, there is no data that needs to entered anywhere. Once you spy on the Agent Name field, you would note that the hierarchy in the Object Spy window consists of 2 elements – Dialog and WinEdit (image shown below). Once you start working with this approach, you will be able to work real quickly with the Object Spy because you would get an idea about the properties that usually go with different types of objects.
Once you are able to run the excel statements from QTP, you can be sure that the logic is working fine. For ease of understanding, you can check the below image which shows the low level flow of a test case as per this framework. The more you work on this framework, there would come a time when you would mostly need to write the flow in the excel sheet only. Since the test case name and sheet names are same, the function fnReadExcel will call the appropriate sheet and execute the flow provided in the excel sheet. Just make sure that whenever you encounter a new keyword, you have to add it in the excel sheet and write corresponding action in the function library. Please note that these changes or improvements are not available in the attached framework. You can try to modularize this flow where instead of having the complete test case flow in one excel sheet, you can try adding just a module, like login or create order in one excel sheet.
To avoid this, you can try to separate the data from the flow by adding it to a separate excel sheet.
So the list of actions would be the same in different tests but one test uses different actions and ignores some that the other test uses. This is the reason we are referring to this framework as the one where keywords are mapped to Operations. 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. Side by side, we will also mention whether we will be using those components in our present framework or not. To store these 3 test cases in the excel sheet, you can either create 1 excel workbook with 3 different sheets. This is because almost all the important things that your framework does will be scripted in the the function library only.
Also most of the important functionality and logic of your framework is written in the function library. The image below shows how the test case excel sheet will look like if you store the data separately. And this knowledge will surely help us come up with better approach for our future projects. Once you are comfortable writing the first test case, the remaining ones will be fairly easy to tackle. Since there will always be only one object on which you will need to perform some operation, so there would be no hierarchy of objects in this column. And from the structure of the excel sheet that we mentioned above, it can easily be made out that the object Dialog with its properties would go in columns A and B, and the object WinEdit and its properties will go in columns C and D.
Associate the function library with the test case and call appropriate functions that will run the test case.
This way you would be able to change the data without touching the flow and you can also re-run the same flow multiple times by using a loop. Since most of the objects can be identified with 1 or 2 properties (sometimes 3), you can easily go with 1 or 2 additional columns. Let us see some of the important things that a function library does in a Keyword Driven Framework.
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). Can we consider the keyword driven framework If the validations are very dynamic ( unfortunately almost all the applications have the dynamic validations).
Only column E will have some value which will depict the operation that needs to be performed. Will that at some point become a problem for QTP which seems keen on doing tests by row rather than column? It has easy-to-use tabular test data syntax and utilizes the keyword-driven testing approach. Without frameworks we will place all our code and data in same place which is neither re-usable nor readable.
Using Frameworks, produce beneficial outcomes like increase code re-usage , higher portability , reduced script maintenance cost etc There are mainly three type of frameworks created by Selenium WebDriver to automate manual testcases Data Driven Test Framework Keyword Driven Test Framework Hybrid Test Framework Data Driven Test Framework In data driven framework all of our test data is generated from some external files like excel, csv, XML or some database table. Now the AUT can have hundreds of button on a page, to identify a Login button, in excel we will input Object Name as loginButton & object type as name (see highlighted row in above image).

How to take pictures of stars with canon rebel t3i manual
Photoshop tricks photography

Comments to «Keyword driven framework using coded ui»

  1. BakuStars on 01.12.2013 at 11:21:23
    The technical jargon and might simply blur remind us of these nice moments we spent midst of the display.
  2. Sabishka on 01.12.2013 at 16:47:55
    Greater than only a few easy Hue-Saturation shifts and explores the.