Wednesday, May 28, 2008

How to Write Script

Here I am giving an idea of how we can write the script in different ways
Here I am taking an example to write a statement to click on a specified button.
I took two conditions, first one is when we are using object repository, second one is when we are not using object repository (Using Descriptive Programming)

Using Object Repository:

'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
OR
Set btnObject=Window("Flight Reservation").WinButton("Update Order") 'Assigning button 'object to an object variable

'3rd Method -
With Window("Flight Reservation") 'Using with statement
.WinButtton("Update Order").click
End with

Usingh Descriptive Programming :

'4th Method -
Window("text:=Flight Reservation").WinButton("text:=&Update Order").click

'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) 'Filtering 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 a window object to a constant
Public const btnUpdate="text:=&Update Order" 'Assigning a button object to a constant
window(wndFlight).WinButton(btnUpdate).click 'clicking on a button using constants

No comments:

Post a Comment