Wednesday, 21 March 2012

Methods And Operations in QTP

This article gives the details about some of the frequently used QTP methods and its operations. We have the following methods.

  • Activate: This method is to activate Windows/ Dialogs
          Syntax: Object Hierarchy.Activate
           Example: Window("Flight Reservation").Activate
  • Click: This method to click the objects.
          Syntax: Object Hierarchy.Click
          Example:Window("Flight Reservation"). WinButton("Login").Click
  • Close: This method to close the browsers, windows,dialogs etc..
          Syntax: Object Hierarchy.Close

          Example:Window("Flight Reservation").Close
  • dbClick: This method to double click the objects.
  • Set: This method can be for any one of the following operation
          01. Set the values to the edit box 
                Syntax: Object Hierarchy.Set
                Example: Dialog("Login").WinEdit("UserName").Set "STC")
          02. To select the radio buttons
                Syntax: Object Hierarchy.Set
                Example: Window("Flight Reservation").WinRadioButton("Business").Set
          03. To Select or Deselect the checkboxes
       Syntax: Object Hierarchy.Set "ON/OFF"
       Example: Window("Flight Reservation").WinCheckBox("Business").Set "ON"

  • Select Method:It is used for selecting an item from a combo box or list box.
       Syntax: Object “item”
       Example:Window("Flight Reservation").WinComboBox("Fly From:").Select "India"
       Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "1222572
  • GetVisibletext: It returns Text from the specified area.
       Syntax: Variable =object hierarchy.getvisibletext
       Example:bb=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText
       msgbox bb
  • GetRoproperty:It returns current object property value. It can be used for getting any object’s, any property value.
       Syntax: Variable = object hierarchy.getroproperty (“property name”)
       Example: aa=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty ("width")
       msgbox aa
  •  Navigate Method:It opens a specified URL in the Browser.
     Syntax: object hierarchy.navigate “URL”
     Example: Browser("Yahoo!").Navigate
  •  Getitemscount: It returns number of items in a combobox.
    Syntax: Variable=object hierarchy.getitemscount
    Example: a=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
    msgbox a
  • Getcontent: It returns all items from a combobox.
    Syntax: variable=object hierarchy.GetContent
    Example:y=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
    msgbox y
  • Exist property: It checks whether the object is available or not.
    Syntax: Object hierarchy.exist(time in seconds)
    Example: Window("Flight Reservation").Exist(5)


Post a Comment

Back To Top