Test Object Model
It is a collection of objects that are used to represent objects in
application.Basically,object means any data in application that supports
methods and properties. QTP support two types of objects as,
Test Object(TO) :- QTP creates an object during recording mode that correspond to object in application called as Test Object.The properties of objects are stored in in Object Repository that are used to identify object during run session.
Run Time Object(RO) :- The object that QTP uses to identify actual object in application during run session is Run Time Object. QTP uses the properties stored in object repository to identify actual object in application during run session.
You can add objects in object repository simply by recording events in application or by manually in object repository.
Test Object(TO) :- QTP creates an object during recording mode that correspond to object in application called as Test Object.The properties of objects are stored in in Object Repository that are used to identify object during run session.
Run Time Object(RO) :- The object that QTP uses to identify actual object in application during run session is Run Time Object. QTP uses the properties stored in object repository to identify actual object in application during run session.
You can add objects in object repository simply by recording events in application or by manually in object repository.
Various Properties & Methods used in QTP
Activate :
The Activate method is used to activate the dialog boxes/Windows.
Syntax: (Object hierarchy).Activate
Example:
Window("Login").Activate
Dialogue("Login").Activate
Click :
The Click method is used to click on an object, usually buttons.
Syntax: (Object hierarchy).Click
Example:
Window("Login").WebButton("Ok").click
Close :
The Close method is used ot close a window,Dialog box, Browser etc.
Syntax: (Object hierarchy). Close
Example:
Window("Flight Reservation").Close
Browser("Browser").Close
Dblclick (Double Click):
The Dblclick method is used to doubleclick on an object.
Syntax: (Object hierarchy).Dblclick (Co-ordinates)
Example:
Window("Exploring").WinListView("SysListView32").DblClick 73, 120, 1
Set :
The Set method is used in 3 different contexts:
- Setting the value of an edit box:
Syntax: (Object Hierarchy).SET "Value"
Example:
Dialog ("Login").WinEdit("Agent Name").Set "Agent1" - Selecting a Radio Button:
Syntax: (Object Hierarchy).Set
Example:
Window("Flight Reservation").WinRadioButton("Business").Set - Selecting/Deselecting Check boxes:
Syntax: (Object Hierarchy).Set "ON/off"
Example:
Window ("Flight Reservation"). Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
The Select method is used for selecting an item from a combo box or a list box.
Syntax: (Object hierarchy).select "item"
Example:
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12572
GetVisibletext:
The GetVisibletext method is used to return the Text from a specified area.
Syntax: Variable = (Object hierarchy).getvisibletext
Example:
x=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText
msgbox "The Visible Text was :" & x
GetROproperty:
GetROproperty method returns the current runtime object property value. It can be used for getting any run-time object’s, (any) property value.
Syntax: (Object hierarchy).getroproperty ("property name")
Example:
x=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty ("width")
msgbox x
Click here to know more about GetROproperty.Navigate:
The Navigate method opens a specified URL in the Browser.
Syntax: (Object hierarchy).navigate "URL"
Example:
Browser("Yahoo!").Navigate "http://www.google.co.in/"
GetItemsCount:
GetItemsCount method returns the number of items in a combobox.
Syntax: (Object hierarchy).GetItemsCount
Example:
x=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
msgbox x
GetContent:
GetContent method returns all the items from a combobox.
Syntax: (Object hierarchy).GetContent
Example:
x=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
msgbox x
Exist:
The Exist method checks whether the object is available or not.
Syntax: Object hierarchy.exist(time in seconds)
Example:
If Window("Flight Reservation").Exist Then
MsgBox "The Window Exists"
Else
MsgBox "The Window does not Exist"
End If
No comments:
Post a Comment