Keyword Driven Methodology

Keyword Driven Methodology

It is a process of generating tests manually using Shared Object Repositories 

Following are the steps involved in Keyword driven Methodology:

1.    Create Shared Repositories

2.    Associate Shared Object Repository files (or) Load Repository files at Run-time

3.    Generate statements or steps manually. Below are the 4 possible options to generate statements manually or hybrid approach can be used.

a.    Using Expert View in QTP Main window
b.    Using Keyword View in QTP Main window
c.    Using Step Generator
d.    By drag and drop objects from Object Repository to Test Pane

1.    Create Shared Repositories

Shared Repository is created by following the below steps.
a.    Launch the Application.
b.    In QTP, navigate to the path
Resources→Object Repository Manager→Object→Add Object
c.    Select the Application window and click OK button.
d.    Save the repository with a meaningful name.

2.    Associate Shared Repository/s

Associate shared repository files by following the below steps.
a.    In QTP, navigate to the path
Resources→Associate Repositories
b.    Browse and select the Saved Repository file by clicking on “+” Icon.
c.    Select the required actions from Available Actions List box and Add to Associated Actions List box.

•    To confirm whether or not the shared objects are associated with the test, check the objects listed in Object Repository window.
•    Shared objects are not editable and cannot be exported, renamed from Object Repository. Shared objects information can only be modified from Object Repository Manager or in the Source file.

3. Generating Statements or Steps manually


While generating statements, QTP provides contextual menu that shows a list of Built-In Methods/Operations (Green color items), Test Objects (Blue color Items). Test Objects are shown in Contextual menu only when shared repository is associated to the Test. While generating statements, user or tester can select the required methods, test objects directly from the contextual help.

a. Using Expert View 

In QTP Tool, Expert view, generate statements manually by following the below steps.
(I)    Generate statement to launch the application.
For GUI Application - SystemUtil.Run “Path of the application”
Example: SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

For Web application - SystemUtil.Run “Path of the application”,”Application URL”
Example: SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe",””

(II)    Generate statement for each operation to be performed in the AUT with Parent-child object hierarchy.
ParentTestObjectName(“Window Name”).Method Name
Example: Dialog("Login").Activate

ParentTestObjectName (“Window Name”).ChildTestObjectName(“Child Test Object Label”).Method name “value to be entered”
Example: Dialog("Login").WinEdit("Agent Name:").Set "abcd"

Example:  Generate statements manually for “Flight Reservation Login”
SystemUtil.Run " C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set "agent1"
Dialog("Login").WinEdit("Password:").SetSecure "50ab0985ba85c8b619f60cfe532c5dc826af7307”
Password Encoder:
Password can be entered using Set or SetSecure method. When Set method is used password should be entered without encoding, and if SetSecure method is used password should be entered in Encoded Format. To encode the password, QTP provides an integrated tool called Password Encoder.
Navigation: Start menu>Programs>Quick Test Professional>Tools>Password Encoder
Note: External view is same for both Recorded Script and Keyword driven methodology script, but internal process vary. Recorded Script uses Local Repository and Keyword driven methodology script uses Shared Repository.
Load Shared Repository at Run-time
Shared Repository can be loaded at run-time instead of associating it with the test. Using the following statement it can be achieved.
RepositoriesCollection.Add "Shared Repository File Path"
Here, Shared Repository File Path can be Absolute (Complete) Path or Relative Path (just File name).
i.    Absolute path – Need to provide complete path where shared repository file is located.
Example: RepositoriesCollection.Add "C:\Documents and Settings\user\Desktop\Login.tsr"
ii.    Relative Path - To set relative path follow the below procedure.
a.    In QTP Tool, follow the below navigation
b.    Click "+" Icon and browse for the path where shared repository file is located and click Apply button.
c.    Provide only file name in the path, wherever required in the Tests
Example: RepositoriesCollection.Add "Login.tsr"
•    Advantage of using Relative path is Test Portability can be achieved and Tests can be executed on multiple systems easily.
•    Limitation for Relative Path: Relative path is only applicable for Resource files like Shared Object Repository Files, Functional library files, Environment variable files, etc… but not applicable for Application path.

b.    Using Keyword View 

After associating Repository file to the test, navigate to "Keyword View" in QTP tool and follow the below steps.

(I)    Click on Second line in Keyword view
(II)    To Insert Utility statement, take help of Step Generator.
(III)    In Step Generator window
1.    Select Category as "Utility Objects"
2.    Select Object as "SystemUtil"
3.    Select Operation as "Run"
4.    In Arguments section, provide application file path in value column for file argument.
5.    Click "Close" button.
(IV)    Click on next line in "Keyword View"
(V)    Select the Object from Object Repository option.
(VI)    Select appropriate operation for the Object added.
(VII)    Enter value for the selected operation.
(VIII)    Add all the required objects by following the above steps from IV to VII.

c. Using Step Generator
Step Generator is a library of functions and utility objects used to generate recordable and non-recordable steps.
Non-Recordable steps are irregular statements or operation on disabled objects.

(I)    To launch Step Generator, follow the below navigation or Press Short cut Key – F7
        Insert > Step Generator

(II)    In Step Generator window
1.    Select Category as "Utility Objects"
2.    Select Object as "SystemUtil"
3.    Select Operation as "Run"
4.    In Arguments section, provide application file path in value column for file argument.
5.    Select the "Insert another Step" Option and Click Insert button, so that the statements can be entered continuously until the end of the test script.
6.    First statement is added to the Keyword View.
7.    Now, select the Category as "Test Objects”
8.    Click the Object Icon
9.    Select appropriate Test Object and click "OK" button.
10.    Select Operation as appropriate to the selected Test Object.
11.    In Arguments section, provide value for the argument.
12.    Add all the required objects until all the required statements are added to the test by following steps from 5 to 11.
13.    Click "Close" button once all the statements are added.
(III)    Non-recordable steps using Step generator for disabled objects, follow the below navigation.
1.    Launch Step generator and click Object Icon.
2.    Click "hand icon" in step generator and select the disabled object in AUT.
3.    Select "GetVisibleText" as Operation.
4.    Select the option "Return value" and specify a variable to store the value of the disabled object.

d. Drag and Drop Objects from Object Repository to Test Pane:

Follow the below steps to drag and drop objects from Object Repository to Test pane.
(I)    Associate Repository and Open Object Repository.
(II)    In Object Repository window, select the required Object to be added to the test.
(III)    Drag and drop the selected object from Object Repository to Test Pane.
(IV)    Drag and drop the objects required in the Test
•    Using this option we can generate Test object statements only.
•    User need to manually enter the input data in set method of the generated statements.
•    Only one object can be dragged and dropped from Object Repository to Test Pane.


Post a Comment