Tuesday, October 14, 2008

Sample script

'Below script is used to crosscheck the total price of the ticket
'SystemUtil.Run used to open any application

SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"'Login
Dialog("Login").WinEdit("Agent Name:").Set "sundar"'
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "48f2fbefd576dce0d7d715a825e5f31fede59a60"
Dialog("Login").WinEdit("Password:").Type micReturn'book ticket
Window("Flight Reservation").ActiveX("MaskEdBox").Type "1111111111111111"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "sundar"
Window("Flight Reservation").WinEdit("Tickets:").SetSelection 0,1
'parameterize the ticket using data table.
Window("Flight Reservation").WinEdit("Tickets:").Set DataTable("Tickets", dtGlobalSheet)
d=Window("Flight Reservation").WinEdit("Tickets:").getroproperty("text")
msgbox "Number of tickets " &d
Window("Flight Reservation").WinButton("Insert Order").Click
a= Window("Flight Reservation").WinEdit("Price:").getroproperty("text")
msgbox "Price per ticket is " &a
b= Window("Flight Reservation").WinEdit("Total:").getroproperty("text")
msgbox "Total calculated in the application " &b
c= a*d
msgbox "Total calculated" &c '
'After splitting
f=split(b,"$") '$ symbol will not come in our calc..so to split the $ using the split command.
msgbox "After splitting the result" &f(1)
h=cdbl(f(1)) ' cdbl used to round off the value..
msgbox "Total price we calculated" &h
If h=c Then
msgbox "Total price is correct "
else
msgbox "Total is incorrect"
End If
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

No comments: