Tuesday, March 8, 2011

Various Properties & Methods used in QTP

I thought of putting together the various methods (operations) we can do with the objects. Please leave a comment if you find anything missing, so that I can update this list.

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:

  1. Setting the value of an edit box:


    Syntax: (Object Hierarchy).SET "Value"

    Example:
    Dialog ("Login").WinEdit("Agent Name").Set "Agent1"
    
  2. Selecting a Radio Button:

    Syntax: (Object Hierarchy).Set

    Example:
    Window("Flight Reservation").WinRadioButton("Business").Set
    
  3. Selecting/Deselecting Check boxes:

    Syntax: (Object Hierarchy).Set "ON/off"

    Example:
    Window ("Flight Reservation"). Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
    
Select:

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

Want to see the usage of these methods and properties, click on the QTP scripts section.

No comments:

Post a Comment

Please leave your comment here...