51Testing软件测试论坛
标题:
进入不了IF语句
[打印本页]
作者:
le_o_lu
时间:
2011-6-13 15:55
标题:
进入不了IF语句
这是一个很简单的登录测试,但是当我运行到错误密码时,不能进入IF的判断语句
If dialog("Login").Dialog("Flight Reservations").Static("Incorrect password. Please").Exist(5) Then
这句话是不是不能运行进IF语句,但是Exist能自动联想出
SystemUtil.Run PathFinder.Locate("..\samples\flight\app\flight4a.exe"),"",PathFinder.Locate("..\samples\flight\app"),"open"
Dialog("Login").WinEdit("Agent Name:").Set DataTable("username", dtLocalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("password", dtLocalSheet)
Dialog("Login").WinButton("OK").Click
If Window("Flight Reservation").Exist(5) Then
reporter.ReportEvent micPass ,"登录验证","登录成功"
Window("Flight Reservation").Close
else
reporter.ReportEvent micFail ,"登录验证","登录失败"
End If
If dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at").Exist(2)then
Dim err_message
err_message = dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at").GetROProperty("text")
reporter.ReportEvent micFail,"登录失败","错误信息是:"&err_message
dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
dialog("Login").WinButton("Cancel").Click
'else
'reporter.ReportEvent micPass,"登录成功","登录成功"
'window("Flight Reservation").Close
End If
If dialog("Login").Dialog("Flight Reservations").Static("Incorrect password. Please").Exist(5) Then
Dim err_messager
err_messager=dialog("Login").Dialog("Flight Reservations").Static("Incorrect password. Please").GetROProperty("text")
reporter.ReportEvent micFail,"登录失败","错误信息是:"&err_messager
dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
dialog("Login").WinButton("Cancel").Click
End If
If dialog("Login").Dialog("Flight Reservations").Static("Please enter agent name").Exist(5) Then
Dim err_name
err_name=dialog("Login").Dialog("Flight Reservations").Static("Please enter agent name").GetROProperty("text")
reporter.ReportEvent micFail,"登录失败","错误信息是:"&err_name
dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
dialog("Login").WinButton("Cancel").Click
End If
If dialog("Login").Dialog("Flight Reservations").Static("Please enter password").Exist(5) Then
Dim err_password
err_password=dialog("Login").Dialog("Flight Reservations").Static("Please enter password").GetROProperty("text")
reporter.ReportEvent micFail,"登录失败","错误信息是:"&err_password
dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
dialog("Login").WinButton("Cancel").Click
End If
复制代码
来,说明这句话是对的,为什么进入不了呢?
作者:
风雪夜归人
时间:
2011-6-13 16:25
写法是对的,不能进去是说明 dialog("Login").Dialog("Flight Reservations").Static("Incorrect password. Please") 这个对象不存在,好好看一下吧。
作者:
le_o_lu
时间:
2011-6-13 16:34
[attach]73541[/attach][attach]73541[/attach]怎么看对象存不存在呀?我的对象仓库里面有这个啊
作者:
le_o_lu
时间:
2011-6-13 17:29
谢谢风雪夜归人,我把那个对象删了,重新创建了个,可以运行通过了
作者:
17800455
时间:
2011-6-14 09:18
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2