停止加载页面 watir-webdriver [英] Stop loading page watir-webdriver

查看:46
本文介绍了停止加载页面 watir-webdriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Firefox 上停止加载带有 watir-webdriver 的页面?或者有没有办法在我的脚本中强制执行某些内容,即使页面仍在加载?在我的脚本中,网站将挂起,脚本最终会超时.

Is there a way to stop loading a page with watir-webdriver on firefox? Or is there a way to force something in my script even if the page is still loading? At a point in my script, the website will hang and the script eventually timeouts.

推荐答案

您可以使用 Timeout 类强制它在等待一段合理的时间后放弃(这也是 Watir 在内部执行等待的方式)

You can use the Timeout class to force it to give up after waiting a reasonable amount of time (and this is internally how Watir performs it's waits as well)

begin
  Timeout::timeout(10) do
    # perform actions that may hang here
  end
rescue Timeout::Error => msg
  put "Recovered from Timeout"
end

这篇关于停止加载页面 watir-webdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆