Watir脚本偶尔会返回Net :: ReadTimeout错误

我有一个Watir脚本,偶尔和不可预测地返回此错误:

Net::ReadTimeout 

我搜索了这个错误,发现这个问题已经问过。 我按照最佳答案,实施了这个:

 attempts = 0 url = "https:/www.google.com/" begin doc = Watir::Browser.start url rescue Net::ReadTimeout retry end 

但我仍然得到相同的超时错误。

我的网络从未遇到任何连接问题。 我在Ubuntu和Windows 10机器上都出错了。 在此错误表现出来之前,我的代码平均经历了大约30次迭代。 我正在使用Chrome。

有什么建议?

当页面加载时间超过60秒时抛出上述错误,因此请为页面加载编写以下代码

 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" 

现在,您的代码将等待120秒,因为#click导致任何页面加载,并等待通过goto方法加载url