问题
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