QTP GUI scripts

 QTP Windows Scripts

QTP Script examples on Windows based Applications


'Verify Cancel Operation in Login dialog
'Without entering any Data if we select "Cancel" Button then Login Dialog should be disappeared
'After Entering Agent Name, if we select "Cancel" Button then Login Dialog should be disappeared
'After Entering Agent Name & password, if we select "Cancel" Button then Login Dialog should be disappeared
'--------------------------------------------------------------------------------------------------------------------
'Without entering any Data

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
Wait 2
Dialog("Login").WinButton("Cancel").Click

If Not Dialog("Login").Exist(3) Then
Reporter.ReportEvent micPass, "Res","Login Dialog disappeared"
Else
Reporter.ReportEvent micFail, "Res","Login Dialog Exists"
End If

'After Entering Agent Name

If Not Dialog("Login").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"
End If
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "abcd"
Wait 2
Dialog("Login").WinButton("Cancel").Click

If Not Dialog("Login").Exist(3) Then
Reporter.ReportEvent micPass, "Res","Login Dialog disappeared"
Else
Reporter.ReportEvent micFail, "Res","Login Dialog Exists"
End If

'After Entering Agent Name & Password 

If Not Dialog("Login").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"
End If
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "abcd"
Dialog("Login").WinEdit("Password:").SetSecure "4d0b6f021b55a51a991eb71730181137ccad8f19"
Wait 2
Dialog("Login").WinButton("Cancel").Click

If Not Dialog("Login").Exist(3) Then
Reporter.ReportEvent micPass, "Res","Login Dialog disappeared"
Else
Reporter.ReportEvent micFail, "Res","Login Dialog Exists"
End If

''*****************************************************************************************************
'Test Requirement: Verify "Total" in Flight Reservation, wherer Total=Tickets*Price
'Verify for 1 to 10 Orders

'Author:abc

'Date of Creation: 17-12-2010

'Date of Modification: NA

'Pre-requasites:
'Login.tsr, Orders.tsr

'Test Flow:
'Launch the Application
'Login Operation
'Acivate the FR window and Open an Order
'Capture Total, Price, Tickets values
'Convert string type data into double/integer type
'Compare if the Total=Tickets*Price or not?
'Form Loop to open 1 to 10 Orders
'*****************************************************************************************************
Option explicit
Dim Tickets, Price, Total, Order_Number
If Not Window("Flight Reservation").Exist(3)  Then

'Launch the Application and Login Operation
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "abcd"
Dialog("Login").WinEdit("Password:").SetSecure "4d0b752a01e5f01019b38bafb8e6a4073189ef86"
Dialog("Login").WinButton("OK").Click
End If

'Open Order
For Order_Number= 1 to 10 Step 1
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 Order_Number
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

'Capture Total, Price, Tickets values
Tickets = Window("Flight Reservation").WinEdit("Tickets:").GetROProperty("text")
Total = Window("Flight Reservation").WinEdit("Total:").GetVisibleText()
Price = Window("Flight Reservation").WinEdit("Price:").GetROProperty("text")

'Msgbox Tickets: Msgbox Total: Msgbox Price

'Convert string type data into integer/Double
Tickets=Cint(Tickets)
Total=Cdbl (Total)
Price=Cdbl(Price)

'Compare if the Total=Tickets*Price or not?
If Total=Tickets*Price  Then
Reporter.ReportEvent 0, "Res","Total is Correct"
Else
Reporter.ReportEvent 1, "Res","Total is Incorrect"
End If
Next

---------------------------------
''*****************************************************************************************************
'Test Requirement: Verify "Total" in Flight Reservation, where Total=Tickets*Price
'Verify for 1 to 10 Orders
'Export Order Number, Tickets, Price ,Total and Result to an external excel file

'Author:abc

'Date of Creation: 17-12-2010

'Date of Modification: NA

'Pre-requasites:
'Login.tsr, Orders.tsr

'Test Flow:
'Launch the Application
'Login Operation
'Acivate the FR window and Open an Order
'Capture Total, Price, Tickets values
'Convert string type data into double/integer type
'Compare if the Total=Tickets*Price or not?
'Form Loop to open 1 to 10 Orders
'*****************************************************************************************************

Option explicit
Dim Tickets, Price, Total, Order_Number, objExcel, myFile, mysheet, row, Result
Set objExcel=CreateObject("Excel.Application")
Set myFile=objExcel.Workbooks.Open ("C:\Documents and Settings\gcreddy\Desktop\xyz.xls")
Set mySheet=myFile.Worksheets("Sheet1")

'Create column headers in Excel sheet1
row=1
mySheet.Cells(row,"A")="OrderNo"
mySheet.Cells(row,"B")="Tickets"
mySheet.Cells(row,"C")="Price"
mySheet.Cells(row,"D")="Total"
mySheet.Cells(row,"E")="Result"
row=row+1

If Not Window("Flight Reservation").Exist(3)  Then
'Launch the Application and Login Operation
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "abcd"
Dialog("Login").WinEdit("Password:").SetSecure "4d0b752a01e5f01019b38bafb8e6a4073189ef86"
Dialog("Login").WinButton("OK").Click
End If

'Open Order

For Order_Number= 1 to 10 Step 1
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 Order_Number
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

'Capture Total, Price, Tickets values

Tickets = Window("Flight Reservation").WinEdit("Tickets:").GetROProperty("text")
Total = Window("Flight Reservation").WinEdit("Total:").GetVisibleText()
Price = Window("Flight Reservation").WinEdit("Price:").GetROProperty("text")

'Msgbox Tickets: Msgbox Total: Msgbox Price

'Convert string type data into integer/Double
Tickets=Cint(Tickets)
Total=Cdbl (Total)
Price=Cdbl(Price)

'Compare if the Total=Tickets*Price or not?
If Total=Tickets*Price  Then
Result="Total is Correct"
mySheet.Cells(row,"A")=Order_Number
mySheet.Cells(row,"B")=Tickets
mySheet.Cells(row,"C")=Price
mySheet.Cells(row,"D")=Total
mySheet.Cells(row,"E")=Result
Else
Result="Total is InCorrect"
mySheet.Cells(row,"A")=Order_Number
mySheet.Cells(row,"B")=Tickets
mySheet.Cells(row,"C")=Price
mySheet.Cells(row,"D")=Total
mySheet.Cells(row,"E")=Result
End If
row=row+1
Next

myFile.Save
myFile.Close
objExcel.Quit
Set objExcel=Nothing

0 comments:

Post a Comment