le_o_lu 发表于 2011-6-13 15:55:03

进入不了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.ReportEventmicPass ,"登录验证","登录成功"
        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:45

写法是对的,不能进去是说明dialog("Login").Dialog("Flight Reservations").Static("Incorrect password. Please") 这个对象不存在,好好看一下吧。

le_o_lu 发表于 2011-6-13 16:34:00

怎么看对象存不存在呀?我的对象仓库里面有这个啊

le_o_lu 发表于 2011-6-13 17:29:36

谢谢风雪夜归人,我把那个对象删了,重新创建了个,可以运行通过了

17800455 发表于 2011-6-14 09:18:07

:)
页: [1]
查看完整版本: 进入不了IF语句