Net::ReadTimeout (Net::ReadTimeout) Selenium Ruby

15,851

Solution 1

Another option to use RSpec::Retry which adds a retry option for intermittently failing specs.

require 'rspec/retry'

RSpec.configure do |config|
  # show retry status in spec process
  config.verbose_retry = true
  # Try twice (retry once)
  config.default_retry_count = 2
  # Only retry when Selenium raises Net::ReadTimeout
  config.exceptions_to_retry = [Net::ReadTimeout]
end

Solution 2

The default timeout is 60 seconds. One thing to try is to adjust the internal timeout to see if that fixes it:

Capybara.register_driver :selenium do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = 120 # instead of the default 60
  Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile, http_client: client)
end
Share:
15,851
Tom
Author by

Tom

Just getting involved in the world of automation testing. Been dropped in at the deep and have to learn on the job, no training so expect a lot of questions from me, mostly probably tivial!

Updated on June 05, 2022

Comments

  • Tom
    Tom almost 2 years

    I've seen a few posts related to timeout errors within Selenium. This is becoming more and more unbearable as it's rendering my test pack unusable. I'm testing a webpage currently in development.

    I have a regression suite of around 300 test scenarios which has always worked until the latest update to firefox and selenium webdriver. Now for almost every other test i'm getting:

    Net::ReadTimeout (Net::ReadTimeout) errors.

    This can't be coincidence. Would anyone know of what could be causing the sudden timeout problems? I've tried going back to previous versions of webdriver and firefox.

  • randallreedjr
    randallreedjr over 8 years
    Just added rspec-retry gem for pesky Net::ReadTimeout errors on Codeship and it did the trick!