Watir脚本偶尔返回Net :: ReadTimeout错误 [英] Watir script occasionally returning Net::ReadTimeout error
问题描述
我有一个Watir脚本,偶尔且无法预测地返回此错误:
I have a Watir script, that occasionally and unpredictably returns this error:
Net::ReadTimeout
我搜索了此错误,发现此问题已经问过.我遵循了最高答案,并实现了这一点:
I searched this error and found this question already asked. I followed the top answer, and implemented this:
attempts = 0
url = "https:/www.google.com/"
begin
doc = Watir::Browser.start url
rescue Net::ReadTimeout
retry
end
但是我仍然遇到相同的超时错误.
but I'm still getting the same timeout error.
我的网络从未出现任何连接问题.我在Ubuntu和Windows 10机器上都收到错误消息.在此错误显现之前,我的代码平均经过大约30次迭代.我正在使用Chrome.
I've never had any connection issues with my network. I get the error on both an Ubuntu and a Windows 10 machine. My code goes through an average of around 30 iterations before this error manifests itself. I'm using Chrome.
有什么建议吗?
推荐答案
当页面加载时间超过60秒时,会引发上述错误,因此请为页面加载编写以下代码
The above error was thrown when the page load time exceeds for 60 seconds so write the following code for page load
client = Selenium::WebDriver::Remote::Http::Default.new
client.read_timeout = 120 # seconds
driver = Selenium::WebDriver.for :firefox,http_client: client
b=Watir::Browser.new driver
b.goto "www.google.com"
现在,对于由#click
引起的任何页面加载,您的代码将等待120秒,并且还将等待通过goto
方法加载url
.
Now your code would wait for 120 seconds for any page load which has been caused by #click
and also wait to load the url
by goto
method.
这篇关于Watir脚本偶尔返回Net :: ReadTimeout错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!