Dim url
url="C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4b.exe"
If Dialog("Login").Exist(1) Then
OptionalStep.Dialog("Login").WinEdit("Agent Name:").Set DataTable("UserName", dtGlobalSheet)
OptionalStep.Dialog("Login").WinEdit("Password:").Set DataTable("Passwd", dtGlobalSheet)
OptionalStep.Dialog("Login").WinButton("OK").Click
else
'如果QTP不能自己打开被测试程序就使用该功能打开
SystemUtil.Run url
OptionalStep.Dialog("Login").WinEdit("Agent Name:").Set DataTable("UserName", dtGlobalSheet)
OptionalStep.Dialog("Login").WinEdit("Password:").Set DataTable("Passwd", dtGlobalSheet)
OptionalStep.Dialog("Login").WinButton("OK").Click
End If
'检查点
If Dialog("Login").Dialog("Flight Reservations").Exist(2)Then
Dim Errorinfor
'对错误提示信息做一个检查点,并根据实际情况进行参数化
Dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at").Check CheckPoint("Agent name must be at")
Errorinfor=Dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at").GetROProperty("text")
Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
'学习一下Reporter方法的用法
Reporter.ReportEvent micPass, "用户名验证通过,提示信息如下",Errorinfor
OptionalStep.Dialog("Login").Close
else
'如果用户名和密码正确就进入订票页面
If Window("Flight Reservation").Exist (2) Then
Reporter.ReportEvent micPass, "登录验证通过","用户名密码正确"
Window("Flight Reservation").close
End If
End If
参数化内容