水豚增加最大允许页面加载时间 [英] Capybara increase max allowed page load time

查看:196
本文介绍了水豚增加最大允许页面加载时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面有时会加载一分钟以上.假设这是预期的行为,并且不会改变.在这些情况下,我得到Net::ReadTimeout.

I have a page that sometimes loads in over a minute. Assume this is the expected behavior and wont change. In these cases, I get Net::ReadTimeout.

请注意,这是通过单击上一页上的按钮导航到某个页面之后的,而不是ajax请求.因此Capybara.using_wait_time没有帮助.

Note that this is after navigating to a page by clicking a button on the previous page, not an ajax request. Therefore Capybara.using_wait_time doesn't help.

我尝试了一些根本性的事情(其中一些我知道是行不通的),例如:

I have tried a number of radical things (some of which I knew wouldn't work) like:

  • 设置page.driver.browser.manage.timeoutsimplicit_waitscript_timeoutpage_load.
  • 遍历整个对象空间并设置所有Selenium::WebDriver::Remote::Http::Defaulttimeout值.
  • 遍历整个对象空间并设置所有 Net::HTTPread_timeout.
  • page.driver.browser.send(:bridge).http.instance_variable_get(:@http).read_timeout=
  • Setting page.driver.browser.manage.timeouts's implicit_wait, script_timeout and page_load.
  • Looping through the entire object space and setting all Selenium::WebDriver::Remote::Http::Default's timeout value.
  • Looping through the entire object space and setting all Net::HTTP's read_timeout.
  • page.driver.browser.send(:bridge).http.instance_variable_get(:@http).read_timeout=

似乎没有一个工作.这应该是微不足道的,但我仍然找不到解决方法.

None seem to work. This should be very trivial, still I couldn't find a way to do it.

如果您知道与Webdriver无关的解决方案,那就太好了.如果没有-我正在使用.

If you know of a webdriver agnostic solution that would be great. If not - I am using selenium.

推荐答案

Selenium具有许多不同的超时设置,其中一些可以在运行时更改,其他必须在初始化驱动程序时进行设置.您很可能会遇到默认为60秒的Http :: Default超时.您可以通过将自己的实例作为http_client

Selenium has a lot of different timeout settings, some of which can be changed at runtime, others which have to be set when the driver is initialized. You are most likely running into the Http::Default timeout which defaults to 60 seconds. You can override this by passing your own instance into the Selenium driver as http_client

Capybara.register_driver :slow_selenium do |app|
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = 120
  Capybara::Selenium::Driver.new(app, http_client: client)
end

,然后使用:slow_selenium驱动程序进行测试,这将花费一分钟的时间来加载页面

and then use the :slow_selenium driver for tests which will take over a minute to load the page

这篇关于水豚增加最大允许页面加载时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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