标题: 小弟跪求一段特别特别专业的QTP脚本代码 [打印本页] 作者: zhangkun90 时间: 2013-1-25 09:46 标题: 小弟跪求一段特别特别专业的QTP脚本代码 哎 才了解QTP不久,可是现在感觉到迷茫了 不知道 专业的QTP代码书写是啥样的, 我也想知道我看看能不能看懂 非常专业的QTP脚本代码, 所以在这里我想要一段专业点的QTP脚本代码 来读读 看看自己是不是也能写出这样的代码来作者: davy_chen 时间: 2013-1-25 10:10
'========================================================================================
' Test Name : Open Order
'
' Description : This test verifies that an order can be opened through the Open Order Form window by:
' 1. The Order No.
' 2. The Date of Flight
' 3. The Name of Customer
'
' IMPORTANT NOTE!!! : The flight that is to be opened has to be unique to the database. Therefore, the test uses an array variable
' that can be changed by the tester, which holds all the neccessary information on the flight.
'
' Note : The test will insert the order using insert_order() (flt_lib) and will delete the order when finished. If the order is not successfully
' inserted into the database, the test will terminate.
'
' Date : May 5,2004
'========================================================================================
'=========================== Static Variables and Functions ===========================================================
'Dictionary object to hold flight information for insertion. Like the use of Enum
Dim flight
Set flight = CreateObject("Scripting.Dictionary")
flight.Add "Fly From", "Los Angeles" ' Add some keys and items.
flight.Add "Fly To", "Denver"
flight.Add "Date", "060636" ' meaning 06/06/2036
flight.Add "Flight No.", "1"
flight.Add "Class", "First"
flight.Add "Name", "Kenny Rogers"
flight.Add "Tickets","4"
' STEP 1. Opening an order by the Order Number.
RunAction "OpenOrder [FlightLib1]", oneIteration,OrderNum
RunAction "ClearMainWindow [FlightLib1]", oneIteration
' STEP 2. Opening an order by Date of Flight.
RunAction "OpenOrderForm [FlightLib]", oneIteration
Window("Flight Reservation").Dialog("Open Order").Activate
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Flight Date").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinObject("FlightDateEdit").Type flight("Date")
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
'# Checking if application could open order using Date
If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("OK").Exist(2) Then
Reporter.ReportEvent FAIL,"FlightDate: " , " Does not exist in the Database."
Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("OK").Click
Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click
Else
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click
Reporter.ReportEvent PASS,"FlightDate: " , " Flight Existed in the DB and opened successfully"
End If
RunAction "ClearMainWindow [FlightLib1]", oneIteration
' STEP 3. Insert an order by Customer Name.
RunAction "OpenOrderForm [FlightLib]", oneIteration
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("CustomerNameEdit").Set flight("Name")
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
'# Checking if application could open order using Date
If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("OK").Exist(2) Then
Reporter.ReportEvent FAIL,"Name: " , " Such name doesn't exist in the DB."
Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("OK").Click
Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click
Else
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click
Reporter.ReportEvent PASS,"FlightDate: " , " Flight Existed in the DB and opened successfully"
End If
RunAction "ClearMainWindow [FlightLib1]", oneIteration
'put the order number
RunAction "DeleteOrder [FlightLib]", oneIteration,OrderNum
'clear window
RunAction "ClearMainWindow [FlightLib1]", oneIteration作者: zhangkun90 时间: 2013-1-25 10:43 回复 2#davy_chen