昨天研究了登录的代码脚本,借鉴了别人的脚本加上自己的一点点脚本,为了加强自己脚本的编写能力,自己手动写脚本。在编写脚本的同时,也慢慢学会了如何debug脚本。
'定义获得实际输出的提示信息变量
Dim hint_msg
'定义预输出的提示信息变量
Dim hint
'定义实际窗口弹出的变量,为True 则弹出了该窗口,为false则未弹出该窗口
Dim ActualDialogPopup
'请求运行飞机订票系统
InvokeApplication "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
'输入登录名和密码
Dialog("Login").WinEdit("Agent Name:").Set DataTable("user",dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("password",dtGlobalSheet)
Dialog("Login").WinButton("OK").Click
hint=DataTable("hint",dtGlobalSheet)
'判断登陆失败提示窗口是否弹出
If Dialog("Login").Dialog("Flight Reservations").Exist Then
ActualDialogPopup="True"
else
ActualDialogPopup="False"
End If
'获取预期提示对话框弹出情况
ExpectedDialogPopup=DataTable("ExpectedDialogPopup",dtGlobalSheet)
'判断预期和实际对话框的弹出情况,如果实际和预期一致,则打印报告,程序判断正确
if(ActualDialogPopup=ExpectedDialogPopup) then
Reporter.ReportEvent micpass,"登录","程序判断正确"
If ActualDialogPopup="True" Then
'hint_msg=Dialog("Login").Dialog("Flight Reservations").Static("Class Name:=Static").GetROProperty("Text")
hint_msg=Dialog("Login").Dialog("Flight Reservations").WinButton("确定").GetROProperty("attached text")
If (hint=hint_msg) Then
Reporter.ReportEvent micpass,"登录错误提示","错误提示信息正确"
else
Reporter.ReportEvent micfail,"登录错误提示","错误提示信息错误"
End If
Dialog("Login").Dialog("Flight Reservations").winButton("确定").Click
Dialog("Login").Close
else
Window("Flight Reservation").Close
End If
else
Reporter.ReportEvent micfail, "登录","程序判断错误"
If ActualDialogPopup="True" Then
Dialog("Login").Dialog("Flight Reservations").Close
Dialog("Login").Close
else
Window("Flight Reservation").Close
end if
End If