Wednesday, October 30, 2013

Keyword Driven Framework - Web Based

Keyword Driven Framework - Web Based

As the previous two posts (Keyword Driven Framework - one keywords / data file, Keyword Driven Framework - separate keywords / data file) on Keyword Driven Framework, this one has the same base except that it is a web based framework.

Below is the folder structure:



In this framework, the data and keywords are in separate files.

There are four parts to this framework:

1. UFT Test (UFT_Test_Cases)



2. Function Library (Function_Library)

Variable declaration in Function Library


Function 1 in Function Library


Function 2 in Function Library


Function 3 in Function Library


3. An Excel Sheet (Keywords)


4. An ExcelSheet (Data)


What this framework does:

This framework opens the IE, launches Google and searches for some text for example "gmail" and closes IE. This is repeated again, second time with some different text like "QTP".

Let’s try to run the framework. In order to run this framework you have to fulfill the prerequisites as below:

1. Make sure that variable "Excel_Location_Path" and "Excel_Location_PathD" in Function Library correctly points to the data and Keywords file.

2. When you open the test (UFT_Test_Cases), you must associate the Function Library (Function_Library) with the test.
   File (Menu) -> Settings.
In the Test Settings dialog that opens, go to Resources and associate the Function Library.

Now try to Run this framework.

Explanation of the above framework:

As said previously this framework is more or less same as the previous Keyword Driven Frameworks (see beginning of the post), so once you understand those, this will be easy to understand.

UFT Test is calling the first function in Function Library i.e. func_Read_Excel and passing it the names of the sheets of Excel files - Keywords and Data. Function func_Read_Excel is importing the Excel data into two QTP / UFT DataTables. Keywords in one DataTable and Data in another. Each column of a row (in DataTable) is being read in the different variable and then function func_Establish_Hierarchy is being called from there. func_Establish_Hierarchy is creating a hierarchy of objects using Set statement as with previous framework examples [give link to previous KDFs]. At last Execute_Action() function is called and based on the value of sAction_to_Perform's variable, appropriate action (Run, SetValue etc.) is called.