为了账号安全,请及时绑定邮箱和手机立即绑定

如下是执行ruby脚本报错TimeoutError,请问该怎么改?

如下是执行ruby脚本报错TimeoutError,请问该怎么改?

婷婷同学_ 2023-03-16 17:13:03
脚本:require "watir"browser = Watir::Browser.new :iebrowser.bring_to_frontbrowser.maximizebrowser.goto urlbrowser.span(:text=>"cas").wait_until_presentbrowser.span(:text=>"cas").when_present.click错误: C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.6.0/lib/watir-classic/wait.rb:29:in `until': timed out after 60 seconds (Watir::Wait::TimeoutError)from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.6.0/lib/watir-classic/element_extensions.rb:63:in `wait_until_present'from nwmtest.rb:26:in `<main>'
查看完整描述

1 回答

?
拉风的咖菲猫

TA贡献1995条经验 获得超2个赞

因为这个元素在60秒内一直没有展现出来吧,所以报了超时,贴下这个方法的源码:

#
# Waits until the element is present.
#
# @example
# browser.button(:id => 'foo').wait_until_present
#
# @param [Fixnum] timeout seconds to wait before timing out
#
# @see Watir::Wait
# @see Watir::Element#present?
#

def wait_until_present(timeout = 30)
message = "waiting for #{selector_string} to become present"
Watir::Wait.until(timeout, message) { present? }
end

def until(timeout = 30, message = nil, &block)
end_time = ::Time.now + timeout

until ::Time.now > end_time
result = yield(self)
return result if result
sleep INTERVAL
end

raise TimeoutError, message_for(timeout, message)
end

希望对你有帮助


查看完整回答
反对 回复 2023-03-18
  • 1 回答
  • 0 关注
  • 93 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信