Increasing Capybara’s page load timeout value

I recently had a problem with a page which wouldn’t load within the default page load time set by Capybara – resulting in the following Timeout error.

Timeout::Error (Timeout::Error)
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/protocol.rb:140:in `rescue in rbuf_fill'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/protocol.rb:134:in `rbuf_fill'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/http.rb:1177:in `request'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/http.rb:627:in `start'
      .rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/net/http.rb:1168:in `request'

The Capybara documentation doesn’t make it immediately obvious how you would increase the page load timeout configuration value, but after some digging around, I eventually found a solution.

Capybara.register_driver :selenium_firefox do |app|
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = 120 # <= Page Load Timeout value in seconds
  Capybara::Selenium::Driver.new(app, :browser => :firefox, :http_client => client)
end

Taken from => gist.github.com/922296

Advertisements
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s