Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara increase max allowed page load time

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.

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:

  • 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.

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

like image 243
ndnenkov Avatar asked Jul 13 '15 12:07

ndnenkov


1 Answers

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

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

like image 142
Thomas Walpole Avatar answered Nov 08 '22 13:11

Thomas Walpole