Thursday 11 September 2014

Object Repository Part-4


6. Generating Basic script:
From QTP 9.5 version onwards we can create script using Test objects by performing Drag & Drop operation.

7. Add/Remove Description properties:
Some times when there is a similar objects are exist in application then default collected description properties may not sufficient to identify Runtime object, then we can add some other properties for a Test object

Navigation:
Ø  Select “Test object” in OR
Ø  Click on [+] button in Description properties
Ø  Select property name
Ø  Click on “OK”

8. Modify Test object Description properties:
In following scenarios we need to modify Test object description property values
When application object property values are changed in modified build then we need to modify/update corresponding test object description property values in the Object Repository

      Navigation:
Ø  Select Test object in OR
Ø  Click on property value which you want to modify
Ø  Update property value

Or 
Select “Update from application” option in “Object” menu at OR

To handle dynamic Objects
Dynamic object means which property values may changes during runtime based on given input data or selection of option
To handle dynamic objects we use Regular expression in corresponding Test object Description property value
Using RE we specify pattern of text instead of any fixed value, while runtime QTP compares pattern of text to identify runtime object.


Object Repository Part-3

Operations in OR:
  1. Adding Test objects:
To identify runtime objects we should provide test objects into OR
    1. Learning process:
                                                              i.      Auto-learning
                                                            ii.      Pre-Learning
                                                          iii.      By define New Test object Manually (when application not available)

    1. By associating shared OR file

  1. Delete Test objects:
If any unwanted test objects are exist in OR w. r. to script then we can delete those test objects

Note: when we delete parent object from the OR, then by default corresponding object child objects will be deleted from the OR

  1. Highlight in Application:
To find application object w. r. to test object available in OR

Navigation:
Select Test Object in OR >> View menu >> Select “highlight in application”
                             
  1. Locate in Repository:
To find Test object in OR based on application object

Navigation:
Ø  “View” menu in OR
Ø  Select “Locate in Repository”
Ø  Click on Application object
Ø  Click on “OK” after confirmation

  1. Rename Test Object:
Some objects may not contain any specific logical name to identify in that case by default QTP consider those object class as logical name
Ex: WinEdit, winbutton…etc

For better understandability of Test objects we can rename those objects

Navigation:
Ø  Select test object in OR
Ø  Right click on mouse
Ø  Select Rename test object
Ø  Enter name for test object

Note: When we rename test object in OR, that will be effected existing action script


Ex: Write script to click on Graph button in “FR” window by adding all the button class objects information into OR


Object Repository Part-2

Associating shared OR:-
---------------------------
In general we prefer shared OR in organization,
Based on requirement we associate shared OR to an action script
Method1: from “Resources” menu

Navigation:  “Resources” menu

  >>Select “associated repositories”

  >>Click on “+” button

  >>Browse “shared OR “file path

  >>Select “Action name” in available Actions list

  >> Add into associated actions list 

  >>Click “OK” 

Method2: “Resources” menu>>Objrep>>Tools>>Associate rep.


Merge Shared Repositories:-
-------------------------------
We can merge two Shared Repositories into single repositories

Navigation:  OR manager

  >>Tools menu

  >>OR merge Tool

  >>Select the Primary, Secondary file

  >>OK

  We can save it has another file .tsr

* Based on the technology of application the class name of objects are like

Web (Html)  Windows     Java   .Net (Win)   Sap   Sap (win)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Web Edit   Win Edit   Java Edit   SwF Edit   Sap Edit   Sap GUI Edit
Web Button  Win Button  Java Button  SwF Button  Sap Button   SapGUI Button 

Swf-----Standard Win Form 

Object Repository Part-1


Object Repository
It has objects and it’s properties which are used in the script during runtime
the tool will search for the object repository, based on properties it will recognize the object in application.

Object Repository Types:-
In QTP we have 2 types of OR’s

a.Local OR (per-Action)
b.Shared OR


a.Local OR:-
------------------
It is a default OR type for each action in QTP

 For each action QTP provides individual Local OR

 When we save\open test by default QTP implicitly save\open corresponding Local OR
  w.r to test

 **Local OR file extension is .bdb (Berkeley DB) from QTP 9.2 version

Disadvantage:

Local OR test objects are not reusable for other actions

Local OR files are not possible to open explicitly
  (by open test in QTP only we can see the test object in Local OR)

b.Shared OR file:-
------------------
In General we prefer Shared OR file in Organization

Where as explicitly TE has to create shared OR file by collecting required Test objects

information and he need to associate shared repository file to the required action

Shared OR file extension is .tsr (Test shared Repository / Test Script Rpository)

Advantage: -
---------------

Shared OR file we can reuse for different actions in different tests

Maintaining all test objects at one location is easy when updates are required

To modify The Shared Object Repository Select Enable for editing and then modify

Nav: Resources>>Objrepositorymanager>>File>>open sharedobjRep>>Filemenu>Enable





Launching application using Script PART-2


VB Script for web based application to perform operations

Object type
Object Class
Browser
Browser(“Browser name”)
Page
Page(“Page name”)
Frame
Frame(“Frame name”)
Table
WebTable(“Table name”)
Link
Link(“Link name”)
Edit box/Text box
WebEdit(“Edit box name”)
List box/combobox
Weblist(“list box name”)
Check box
WebCheckbox(“checkbox name”)
Push button
WebButton(“object name”)
Image
Image(“image name”)
Pop-up window
Dialog(“pop-up window name”)
Radio group
webRadiogroup(“Group name”)

VB Script statement to perform operation on web based application object
Browser(“Browser name”).Page(“Page name”).Objectclass(“object name”).Method “Value”

Ex: Write script to open mercury web tours application and to register user
Step 1: open web application (URL= http://newtours.demoaut.com)
Step 2: click on “Register here” link
Step 3: enter “Rahul” in “First Name” edit box
Step 4: enter “Mindq” in “Last Name” edit box
Step 5: select “INIDIA” in “Country” list box
Step 6: enter “Rahul” in “User name” edit box
Step 7: enter “Mindq” in “Password” edit box
Step 8: enter “Mindq” in “Confirm password” edit box
Step 9: click on “Submit”

Script:
invokeapplication "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://newtours.demoaut.com"
browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Link("Register here").Click
browser("Welcome: Mercury Tours").Page("Register: Mercury Tours").WebEdit("firstName").Set"Praveen"
browser("Welcome: Mercury Tours").Page("Register: Mercury Tours").WebEdit("lastName").Set "Kalepu"
browser("Welcome: Mercury Tours").Page("Register: Mercury Tours").WebList("country").Select "INDIA"
browser("Welcome: Mercury Tours").Page("Register: Mercury Tours").WebEdit("email").Set "rakesh"
browser("Welcome: Mercury Tours").Page("Register: Mercury Tours").WebEdit("password").Set "rakesh1"
browser("Welcome: Mercury Tours").Page("Register: Mercury Tours").WebEdit("confirmPassword").Set "rakesh1"
browser("Welcome: Mercury Tours").Page("Register: Mercury Tours").Image("register").Click

Ex: Write script to perform login operation in mercury web tours application
Step 1: enter user name as “Rahul005”
Step 2: enter pwd as “Mindq”

Step 3: click on “sign-in” button

=========================================
=========================================

Launching application using Script PART-1

Launching application using Script:
There are 2 types of functions to launch application during runtime

  1. Invokeapplication:
  2. SystemUtil.Run:
  1. Invokeapplication:
Using this function we can open applications during runtime (only .exe file)
Where as it supports only .exe files
Syntax: to open windows based applications
Invokeapplication “path of application”

Ex: write script to open “Calculator” application

Syntax: to open web based applications
Invokeapplication “ browser_path Application_URL”

Ex: write Script to open Google.co.in web site
Script:
invokeapplication "C:\Program Files\Internet Explorer\IEXPLORE.EXE www.google.co.in"

  1. SystemUtil.Run:

     Using this utility function we can open application and any system file during runtime

     This function will return status into test result window

     Syntax: to open any system file/windows based application
     SystemUtil.Run “Path of file/application”

    Syntax: to open web based application
    SystemUtil.Run “browser_path”, “application_URL”
    
    Script:

    systemutil.Run "iexplore.exe",www.google.co.in



Object Identification during Runtime/Test Object Model (TOM)


Test Object: 
Objects which are exist in “Object Repository”
Where Test object consist some of the description property values

Runtime Object: 
Objects which are exist in AUT
Where Runtime object consist all the property values which are provided by developer
During runtime QTP use Test object description property values to identify runtime object in AUT, based on logical name used in the script

Learning process:
Adding new test objects into Object Repository is called learning or application maps
Learning can be performed in 2 ways:

1.      Auto-learning:
During recording by default QTP captures application object description properties on which object we perform operation and then collected description properties QTP maintain in the local OR
2.      Pre-learning:
When we write script manually at that time QTP is not able to collect corresponding Test object description properties.TE is responsible to add required Test objects in the Object repository based on which objects QTP need to perform operations
Navigation:
Ø  “Resources” menu in QTP
Ø  Select “Object Repository”
Ø  “Object” menu in OR
Ø  Select “Add objects to local” option
Ø  Click on application object
Ø  Click on “OK” after confirmation
Ø  Select Filter option based on requirement
Ø  Click on “OK”

Note: During pre-learning when we select parent object in application then QTP provides following Filter options
a.      Selected object only:
When we select this option QTP collects only parent object information without child objects

b.      Default object types:
In general we prefer this filter option
When we select this option QTP collects parent object and child objects information on which objects we can perform operations

c.       All object types:
When we select this option QTP collects parent object and all the child objects information including static text and static images

d.      Selected object types:
Using this filter option we can add specified class objects information only from parent object

Ex: add all the “Button” class test objects information only into OR from “FR” window

Ex: write script to select “Font…” option in “Format” menu in Notepad application



Tuesday 9 September 2014

Shortcut Keys for QTP


Short keys:

Ctrl+M       à to comment block of statements

Ctrl+Shift+M àto uncomment block of statements

Ctrl+W       à to apply “With” to script

Ctrl+Shift+W àto remove “With” from script

Ctrl+F7      àto check syntax error

Shift+F2     àto Rename Action

F3              à for Standard Recording

Shift+Alt+F3           à analog recording

Ctrl+Shift+F3         àLow-level recording

F4              àto stop Recording/Run

F5              àto Run script

Ctrl+R                    àto open Object Repository

F9              àBreakpoint


F11                        àStep Into

Password Encoder

Password Encoder:
It is built-in tool in QTP to generate encoded string for given password value

Navigation:
Ø  Start menu
Ø  All programs
Ø  QTP
Ø  Tools
Ø  Select “Password Encoder”

Ex: write script to open 5th order number record in “FR” application
Step 1: activate “FR” window
Step 2: select “Open Order…” option in “File” menu
Step 3: activate “Open Order” sub window
Step 4: set “ON” for “Order No.” check box
Step 5: enter value “5” in edit box
Step 6: click on “OK” button

Script:
Window(“FR”).Activate
Window(“FR”).WinMenu(“Menu”).select “File;Open Order…”
Window(“FR”).Dailog(“Open Order”).Activate
Window(“FR”).Dialog(“Open Order”).WinCheckbox(“Order No.”).set “ON”
Window(“FR”).Dialog(“Open Order”).WinEdit(“Edit”).set “5”
Window(“FR”).Dialog(“Open Order”).winbutton(“OK”).click


Using “With” statements:
Using “With” statement in the script we can avoid writing parent object in each step

Syntax:
With objectclass (“object name”)
                  .Method “value”
                  ------
                  -----

End With

Object Spy



Object Spy:
Using this component we can view the application object property values and operations which we can perform on that object

Navigation:
Ø  Click on “Tools” menu in QTP
Ø  Select “Object Spy”
Ø  Click on hand icon button
Ø  Click on application object which object properties and operations do you want to view

Note:
Window class object will contain Menu options
Dialog class object will not contain menu options

Ex: write script to perform login operation

Step 1: Activate Login window
Step 2: enter “Mindq” in “Agent Name:” edit box
Step 3: enter “Mercury” in “Password:” edit box
Step 4: click on “OK” button

Script:
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).set “Mindq”
Dialog(“Login”).WinEdit(“Password:”).set “Mercury”

Dialog(“Login”).WinButton(“OK”).click

VbScript in QTP Part-3


Vb Script for standard windows based applications

Objects
Object class in VB Script
Main window
Window (“window name”)
Sub window/pop-up window
Dialog(“sub window name”)
List box\combobox
WinCombobox(“list box name”)
Check box
WinCheckbox(“check box name”)
Radio button
WinRadiobutton(“Radio button name”)
Edit box\text box
WinEdit(“Edit box name”)
Push button
WinButton(“object name”)
Menu object
**WinMenu(“Menu”)

Note: application object representation in VB Script

Syntax: ObjectClass(“object logical name”)

Operations
Test object methods
Activate a window
Activate
Enter value in edit box
Set “Value”
Enter value in pwd edit box
SetSecure “encoded string”
Or Set “Value”
Select option in menu
Select “Menu name;option”
Select item in a list box
Select “items” or select (item index)
Click on push button,link, image
Click
Select option in webradiogroup
Select(“#index”)
Check box operation
Set “ON”/”OFF”
Radiobutton operation
Set

Ex: write script to perform multiply operation on “Calculator” application
Step 1: activate “Calculator” window
Step 2: click on “C” button
Step 3: click on “5” button
Step 4: click on “*” button
Step 5: Click on “9” button
Step 6: click on “=” button

Script:
Window(“Calculator”).Activate
Window(“Calculator”).WinButton(“C”).click
Window(“Calculator”).WinButton(“5”).click
Window(“Calculator”).WinButton(“*”).click
Window(“Calculator”).WinButton(“9”).click
Window(“Calculator”).WinButton(“=”).click


Ex: write script to perform submit operation in a “Sample” window
Step 1: Activate Sample window
Step 2: enter “Rajesh” in “Name:” edit box
Step 3: select “30” in “Age:” list box
Step 4: select Male radio button
Step 5: click on “submit” button

Script:
Window(“Sample”).Activate
Window(“Sample”).WinEdit(“Name:”).set “Rajesh”
Window(“Sample”).Wincombobox(“Age:”).select “30”
Window(“Sample”).WinRadiobutton(“Male”).set
Window(“Sample”).WinButton(“submit”).click