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:
page.driver.browser.manage.timeouts
's implicit_wait
, script_timeout
and page_load
.Selenium::WebDriver::Remote::Http::Default
's timeout
value.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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With