Watir script occasionally returning Net::ReadTimeout error

只愿长相守 提交于 2019-12-24 08:49:16

问题


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.

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.

Any suggestions?


回答1:


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"

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.



来源:https://stackoverflow.com/questions/50431267/watir-script-occasionally-returning-netreadtimeout-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!