51Testing软件测试论坛

标题: Watir对于弹出框的问题,急!!在线等 [打印本页]

作者: seagull1985    时间: 2011-6-17 11:52
标题: Watir对于弹出框的问题,急!!在线等
这是从网上找到的一个方法, 但是还是找不到弹出框,RET的值为0,弹出来的就是一个ALERT的框框,各位高人指点一下迷津,本人正在学习中,不知道是什么原因捕获不到弹出框。

def check_for_popups
@autoit = WIN32OLE.new('AutoItX3.Control')
  #
  # Do forever - assumes popups could occur anywhere/anytime in your application.
  loop do
  # Look for window with given title. Give up after 1 second.
  ret = @autoit.WinWait('Windows Internet Explorer','',3)
  #ret = WinActivate("Windows Internet Explorer","")
  #autoit.ControlClick("Windows Internet Explorer","","[CLASS:Button; INSTANCE:1]",2)
  puts(ret) #
  # If window found, send appropriate keystroke (e.g. {enter}, {Y}, {N}).
  if (ret==1) then @autoit.Send("{Enter}") end
  #   
  # Take a rest to avoid chewing up cycles and give another thread a go.
  # Then resume the loop.
  sleep(3)
  end
  end


@popups=TC_recorded.new
$popup = Thread.new{@popups.check_for_popups} # start popup handler
at_exit{Thread.kill($popup)}
作者: lovecy    时间: 2011-6-29 16:51
你懂不懂程序里的每一句的意思先?




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2