Monday, June 4, 2012

How to click a button in 7 ways



'1st method
Window("Flight Reservation").WinButton("Update Order").Click    'Common Method


'2nd method
Set wndObject=Window("Flight Reservation")    ' Assigning window object to an object variable
wndObject.WinButton("Update Order").Click        ' Following normal syntax ( click on a button)


' OR


Set btnObject=Window("Flight Reservation").WinButton("Update Order")    ' Assigning Button object to an object variable
btnObject.Click    ' Clicking on button using button object variable


'3rd method
With Window("Flight Reservation")        ' Using With statement
            .WinButton("Update Order").click
End with


'4th method
Window("text:=Flight Reservation").WinButton("text:=&Update Order").Click    ' Descriptive programming


'5th method
Set oDes=Description.Create            ' creating a description object
oDes("nativeclass").value="Button"    ' assigning description to the description object
oDes("text").value="&Update Order"
Window("text:=Flight Reservation").winbutton(oDes).click    ' clicking on button using the created description object


'6th method
Set oDes=Description.Create        '   creating a description object
set btnObjList=Window("text:=Flight Reservation").ChildObjects(oDes)    ' Flitering the objects
For objIndex=0 to btnObjList.count-1
        propVal=btnObjList(objIndex).getroproperty("text")    ' Get property value from object
        If propVal="&Update Order" Then        ' Compare property value
                btnObjList(objIndex).click        ' Click on identified object
                Exit for        ' Exit For loop after clicking on the button
        End If
Next


'7th method
Public const wndFlight="text:=Flight Reservation"    ' Assigning window object description to a constant
Public const btnUpdate="text:=&Update Order"      ' Assigning Button object description to a constant
Window(wndFlight).winbutton(btnUpdate).click        ' Click on a button using description constants

1 comment:

Different Types of Keyboard Inputs : Type, SendKeys & Device Replay

1. Most objects support the TYPE method.  Type will enter the specified string into an object or perform a certain keyboard combinat...