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能自动联想出
  1. SystemUtil.Run PathFinder.Locate("..\samples\flight\app\flight4a.exe"),"",PathFinder.Locate("..\samples\flight\app"),"open"
  2. Dialog("Login").WinEdit("Agent Name:").Set DataTable("username", dtLocalSheet)
  3. Dialog("Login").WinEdit("Password:").Set DataTable("password", dtLocalSheet)
  4. Dialog("Login").WinButton("OK").Click
  5. If Window("Flight Reservation").Exist(5) Then
  6.         reporter.ReportEvent  micPass ,"登录验证","登录成功"
  7.         Window("Flight Reservation").Close
  8.         else
  9.         reporter.ReportEvent micFail ,"登录验证","登录失败"
  10. End If
  11. If dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at").Exist(2)then
  12.         Dim err_message
  13.         err_message = dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at").GetROProperty("text")
  14.         reporter.ReportEvent micFail,"登录失败","错误信息是:"&err_message
  15.         dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
  16.         dialog("Login").WinButton("Cancel").Click
  17.     'else
  18.         'reporter.ReportEvent micPass,"登录成功","登录成功"
  19.         'window("Flight Reservation").Close
  20.        
  21. End If

  22. If dialog("Login").Dialog("Flight Reservations").Static("Incorrect password. Please").Exist(5) Then
  23.         Dim err_messager
  24.     err_messager=dialog("Login").Dialog("Flight Reservations").Static("Incorrect password. Please").GetROProperty("text")
  25.         reporter.ReportEvent micFail,"登录失败","错误信息是:"&err_messager
  26.         dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
  27.         dialog("Login").WinButton("Cancel").Click

  28. End If

  29. If dialog("Login").Dialog("Flight Reservations").Static("Please enter agent name").Exist(5) Then
  30.         Dim err_name
  31.         err_name=dialog("Login").Dialog("Flight Reservations").Static("Please enter agent name").GetROProperty("text")
  32.         reporter.ReportEvent micFail,"登录失败","错误信息是:"&err_name
  33.         dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
  34.         dialog("Login").WinButton("Cancel").Click
  35.        
  36. End If

  37. If dialog("Login").Dialog("Flight Reservations").Static("Please enter password").Exist(5) Then
  38.         Dim err_password
  39.         err_password=dialog("Login").Dialog("Flight Reservations").Static("Please enter password").GetROProperty("text")
  40.         reporter.ReportEvent micFail,"登录失败","错误信息是:"&err_password
  41.         dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
  42.         dialog("Login").WinButton("Cancel").Click
  43.        
  44. 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