Friday, 24 July 2015

METHODS IN QTP


                          Methods

            First method – Capture bitmap:
                        It is used for capturing a snap shot of an object or an window during executin and stores it in the desired location

     Syntax: Object hierarchy.capturebitmap “Path of the location with a file name.bmpextension”
            Example:
     Window(“flight Reservation”).dailog(“openorder”).winbutton(“ok”).capturebitmap”D:\fl_automation\b1.bmp”

            Second Method- Exist method:
          It is used for checking the objects existence if the object is existing then it will return a value True, and make the QTP to continue the execution, If at all the object is not existing it will make the tool to wait till object exists. Once the object exists it will return true and make the QTP to continue the execution. If at all the object is not existing up to the maximum time then it will return false and make the QTP to continue the execution
                

            Syntax: variable=object hierarchy.exists(time in seconds)
            Example: Var= window(“flight reservation”).exists(12)

            Wait property:
Wait property is used for making the tool to wait based on the object properties value
     Syntax: object hierarchy.wait property “property name”, property value, extra time in mille seconds

              Wait: it is used for making the tool to wait till the specified time is elapsed.
              Syntax: Wait” Time in seconds”

              Simple and regularly used methods: -
                  
              The first method among those is click method.

              1. Click method: -
              Click method is used for clicking on specified object
              Syntax: Object hierarchy.click(x,y,[button] )

              2. Double click: -
              It is used for double clicking on a specified object
              Syntax: Object hirerarchy.dblclick(x,y, [button])

     3.Set Method: - Set method is used for setting a value in to an edit box or selecting or deselecting acheck box or selecting a radio button
              Syntax:      Object hirerearchy.set”value”
              Object hierarchy of check box.set “on/off”
              Object hierarchy of radiobutton.set


                             Activate Method:
It is used for activating a window or a dialog.
Syntax: Object hierarchy. Activate

                             Close Method:
                                      It is used for closing the window or a browser
                                      Syntax: Object hierarchy. Close

                             Set Secure:
                   Set secure method is used for setting an encrypted data in to an edit box

                             Type Method:
                   Type method is used for performing any kind of key board related operation
                                      Syntax: Object hierarchy. Type key value
                                      Example:
                                      Dialog (“login”). Winedit(“agent name”).type mic tab

                             Get to property:   Gettoproperty is used for getting the text objects properties value

                             SYNTAX: var= object hierarchy.gettoproperty (“property name”)
                             Example: var= vbwindow9”form1”).vbbutton(“add”).gettopropery(“text”)

          Note: Text objects property means the properties present in the object repository+properties present in the secret place

                             Set to property:
                   SettopropertyIs used for setting the text objects properties value temporarily during the execution
                             SYNTAX: Object hierarchy.settoproperty “property name”,”property value”



                             GetRoProperty:
                   It is used for getting the currant value of the runtime objects property
                                      Syntax: Variable=Object hierarchy.getroproperty(“property name”)


                             VbWindow("CALCULATOR").Activate
                             VbWindow("CALCULATOR").VbEdit("VALUE1").Set "12"
                             VbWindow("CALCULATOR").VbEdit("VALUE2").Set "12"
var=VbWindow("CALCULATOR").VbButton("ADD").GetTOProperties("enabled")
                             MsgBoxvar
                             VbWindow("CALCULATOR").VbButton("ADD").Click
                             var2=VbWindow("CALCULATOR").VbEdit("RESULT").GetROProperty("text")
                             MsgBox var2
                             VbWindow("CALCULATOR").VbButton("SUB").Click
                             VbWindow("CALCULATOR").VbButton("MUL").Click
                             VbWindow("CALCULATOR").VbButton("DIV").Click
                             VbWindow("CALCULATOR").VbButton("CLEAR").Click


No comments:

Post a Comment