-----------------------------------------------------
'Write a function to count Buttons in FR Window
Function Count_Buttons()
Dim oButton, Buttons, i
Set oButton=Description.Create
oButton("Class Name").value="WinButton"
Set Buttons=Window("text:=Flight Reservation").ChildObjects(oButton)
Msgbox Buttons.Count
End Function
Call Count_Buttons()
----------------------------------------------------------------------------------------------------
'Write a function to count Objects based on specified class in FR Window
Function Count_Objects(obj)
Dim oObject, Objects, i
Set oObject=Description.Create
oObject("Class Name").value=obj
Set Objects=Window("text:=Flight Reservation").ChildObjects(oObject)
Msgbox Objects.Count
End Function
---------------------------------------------------------------------
Call Count_Objects("WinButton")
Call Count_Objects("WinEdit")
Call Count_Objects("WinRadioButton")
--------------------------------------------------------------------------------------------------
'Write a function for returning multiple results
Function Verify_UpadateButton()
Window("Flight Reservation").Activate
Before_Open= Window("Flight Reservation").WinButton("Update Order").GetROProperty("Enabled")
If Before_Open=False Then
Verify_UpadateButton="Update Button is in Disabled state"
Else
Verify_UpadateButton="Update Button is in Enabled state"
End If
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "1"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
After_Open= Window("Flight Reservation").WinButton("Update Order").GetROProperty("Enabled")
If After_Open=True Then
Verify_UpadateButton="Update Button is in Enabled state"
Else
Verify_UpadateButton="Update Button is in Disabled state"
End If
End Function
x=Verify_UpadateButton()
Msgbox x
-----------------------------------------------------------------------------------------------------------
'Write a function for Open Order
Function Open_Order(Ord)
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set Ord
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
OrderNo = Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")
'Msgbox OrderNo
If Cint (OrderNo) = Ord Then
Open_Order = Ord&" Order Opened"
Else
Open_Order = Ord&" Order Not Opened"
End If
Msgbox Open_Order
End Function
Call Open_Order(6)
-------------------------------------------------------------------
'Write a function for Update Order
Function Update_Order(Tickets)
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "2"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Tickets:").Set Tickets
Window("Flight Reservation").WinButton("Update Order").Click
Wait 10
Message = Window("Flight Reservation").ActiveX("Threed Panel Control").GetROProperty("text")
If Message = "Update Done..." Then
Update_Order="Order Updated"
Else
If Window("Flight Reservation").Dialog("Flight Reservations").Exist(3) Then
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("OK").Click
Window("Flight Reservation").WinButton("Button_2").Click
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("No").Click
End If
Update_Order="Order Not Updated"
End If
Msgbox Update_Order
End Function
ex 2:
----------------------------------------------------------------------------
'Write a function for returning multiple values
'(Condition1: Before open an Order "Update Order" Button should be Disabled)
'(Condition2: After open an Order "Update Order" Button should be Enabled)
Function UpdateButton_State()
Dim Before_Open, After_Open, Verify1, Verify2
Window("Flight Reservation").Activate
Before_Open = Window("Flight Reservation").WinButton("Update Order").GetROProperty("enabled")
If Before_Open =False Then
Verify1="Update Order Button Disabled"
Else
Verify1="Update Order Button Enabled"
End If
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "1"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
After_Open = Window("Flight Reservation").WinButton("Update Order").GetROProperty("enabled")
If After_Open =True Then
Verify2="Update Order Button Enabled"
Else
Verify2="Update Order Button Disabled"
End If
UpdateButton_State= Array(Verify1, Verify2)
End Function
Result = UpdateButton_State()
Msgbox Result(0)
Msgbox Result(1)
=========================================
Scripting exampless
----------------------------
'Verify "Cancel" Operation
'Condition1: Without entering any data if user selects "Cancel" Button then Dialog should be dissapeared
'Condition2: After entering some fields if user selects "Cancel" Button then Dialog should be dissapeared
'Condition3: After entering all fields if user selects "Cancel" Button then Dialog should be dissapeared
'Without entering any data if user selects "Cancel" Button then Dialog should be dissapeared
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinButton("Cancel").Click
If Not Dialog("Login").Exist(3) Then
Reporter.ReportEvent 0, "Verify1","Login Dialog Dissapeared"
Else
Reporter.ReportEvent 1, "Verify1","Login Dialog Exists"
End If
'After entering some fields if user selects "Cancel" Button then Dialog should be dissapeared
If Not Dialog("Login").Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
End If
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinButton("Cancel").Click
If Not Dialog("Login").Exist(3) Then
Reporter.ReportEvent 0, "Verify2","Login Dialog Dissapeared"
Else
Reporter.ReportEvent 1, "Verify2","Login Dialog Exists"
End If
'After entering all fields if user selects "Cancel" Button then Dialog should be dissapeared
If Not Dialog("Login").Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
End If
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("Cancel").Click
If Not Dialog("Login").Exist(3) Then
Reporter.ReportEvent 0, "Verify3","Login Dialog Dissapeared"
Else
Reporter.ReportEvent 1, "Verify3","Login Dialog Exists"
End If
--------------------------------------------------------------------------------------------------------------------------------
'Verify the "Total"
(Condition1: Total = Tickets * Price)
'******************************************************************************************
'Test Name: Verify the Total
'Author: abcd
'Date of Creation: December 1st 2011
'Date of Modification: NA
'Pre-requasites
'Registred Agent
'Resoureces: Login.tsr, abc.vbs, xyz.xls
'Pre-setup:
'Test Flow:
'Launch the Application
'Enter Agent name and Password
'Select default Button
'Open Order
'Read values from Tickets, Price, and Total objects
'Convert the Values
'Compare the values (Total = Tickets * price or not?)
'Close the Application
'******************************************************************************************
Option Explicit
Dim Tickets, Price, Total
'Login Operation
If Not Window("Flight Reservation").Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure "4ed6f213f89431c00ae55f09e07be0174b6e9b04"
Dialog("Login").WinButton("OK").Click
End If
'Open Order
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("OpenOrder").Click
Window("Flight Reservation").Dialog("Open Order").Activate
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("OrderNo").Set "4"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
'Reading Values from Application Objects
Tickets = Window("Flight Reservation").WinEdit("Tickets:").GetVisibleText()
Price = Window("Flight Reservation").WinEdit("Price:").GetVisibleText()
Total = Window("Flight Reservation").WinEdit("Total:").GetROProperty("text")
'Converting the Values
Tickets = Cint (Tickets)
Price = Cdbl (Price)
Total = Cdbl (Total)
'Compare the Values
If Total = Tickets * Price Then
Reporter.ReportEvent micPass," Res","Total is Correct"
Else
Reporter.ReportEvent micFail," Res","Total is InCorrect"
End If
'Close the Application
If Window("Flight Reservation").Exist(3) Then
Window("Flight Reservation").Close
End If
------------------------------------------------------------------------------
'******************************************************************************************
'Test Name: Verify the Total
'Author: abcd
'Date of Creation: December 1st 2011
'Date of Modification: NA
'Pre-requasites
'Registred Agent
'Resoureces: Login.tsr, abc.vbs, xyz.xls
'Pre-setup:
'Test Flow:
'Launch the Application
'Enter Agent name and Password
'Select default Button
'Open Order
'Read values from Tickets, Price, and Total objects
'Convert the Values
'Compare the values (Total = Tickets * price or not?)
'Close the Application
'******************************************************************************************
Option Explicit
Dim Tickets, Price, Total, Login, FR
Set Login = Dialog("Login") : Set FR = Window("Flight Reservation")
'Login Operation
If Not FR.Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Login.Activate
Login.WinEdit("Agent Name:").Set "asdf"
Login.WinEdit("Password:").SetSecure "4ed6f213f89431c00ae55f09e07be0174b6e9b04"
Login.WinButton("OK").Click
End If
'Open Order
FR.Activate
FR.WinButton("OpenOrder").Click
FR.Dialog("Open Order").Activate
FR.Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
FR.Dialog("Open Order").WinEdit("OrderNo").Set "4"
FR.Dialog("Open Order").WinButton("OK").Click
'Reading Values from Application Objects
Tickets = FR.WinEdit("Tickets:").GetVisibleText()
Price = FR.WinEdit("Price:").GetVisibleText()
Total = FR.WinEdit("Total:").GetROProperty("text")
'Compare the Values
If Cdbl (Total) = Cint (Tickets) * Cdbl (Price) Then
Reporter.ReportEvent micPass," Res","Total is Correct"
Else
Reporter.ReportEvent micFail," Res","Total is InCorrect"
End If
'Close the Application
If FR.Exist(3) Then
FR.Close
End If
-----------------------------------------------------------------------------------------------------------------------
'Verify the Price Consistancy for 1 to 10 Orders
'(Condition1: First Class Price = 3 times of Economy Class Price) & (Condition2: Business Class Price = 2 times of Economy Class Price)
'----------------------------------------------------------------------------------------------------------------------
If Not window("Flight Reservation").Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure "4ed82cd0619089d050a75e22749ccfc151544631"
Dialog("Login").WinButton("OK").Click
End If
For i=1 to 10 step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Window("Flight Reservation").WinRadioButton("First").Set
First_Price= Window("Flight Reservation").WinEdit("Price:").GetROProperty ("text")
Window("Flight Reservation").WinRadioButton("Business").Set
Business_Price= Window("Flight Reservation").WinEdit("Price:").GetROProperty ("text")
Window("Flight Reservation").WinRadioButton("Economy").Set
Economy_Price= Window("Flight Reservation").WinEdit("Price:").GetROProperty ("text")
If Cdbl (First_Price) = 3 * Cdbl (Economy_Price) and Cdbl (Business_Price) = 2 * Cdbl (Economy_Price) Then
Reporter.ReportEvent 0, "Res", "Price consistancy is there"
Else
Reporter.ReportEvent 1, "Res", "Price consistancy Not is there"
End If
Window("Flight Reservation").WinButton("Button_2").Click
Window("Flight Reservation").Dialog("Flight Reservations").Activate
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("No").Click
Next
-----------------------------------------------------------------------------------------------------------------
'Verify "Fly From:" (Source) and "Fly To:" Combo boxes
'Condition: Source item should not be present in the Distination List
'Desc: Select items one by one from "Fly From:" Combo box and verify if the item is available or not in"Fly To:"
'Combo box
'-------------------------------------------------------------------------------------------------------------------------------------
Dim From_Count, To_Count, From_Item, To_Item, i, j
If Not Window("Flight Reservation").Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure "4ed83215b50c58772ba3299f064ec6e294811b3d"
Dialog("Login").WinButton("OK").Click
End If
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212"
From_Count = Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
For i= 0 to From_Count-1 Step 1
Window("Flight Reservation").WinComboBox("Fly From:").Select(i)
From_Item = Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("text")
To_Count = Window("Flight Reservation").WinComboBox("Fly To:").GetItemsCount
For j = 0 to To_Count - 1 step 1
Window("Flight Reservation").WinComboBox("Fly To:").Select(j)
To_Item = Window("Flight Reservation").WinComboBox("Fly To:").GetROProperty("text")
If From_Item <> To_Item Then
Reporter.ReportEvent 0, "Res","Test Passed"
Else
Reporter.ReportEvent 1, "Res","Test Failed"
End If
Next
Next
--------------------------------------------------------------------------------------------------------------------------------
No comments
Post a Comment