Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get ReadTimeout using webdrivers selenium on Heroku

I get the following error when using selenium webdrivers on heroku. (rspec->capybara->selenium)

Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)>

I have the heroku-buildpack-google-chrome buildpack, with webdrivers-gem.

And have the following block in spec setup:

chrome_shim = ENV.fetch("GOOGLE_CHROME_SHIM", nil)

Selenium::WebDriver::Chrome.path = chrome_shim

chrome_opts = { "chromeOptions" => { "binary" => chrome_shim } }

Capybara.register_driver :selenium do |app|
    Capybara::Selenium::Driver.new(
      app,
      browser: :chrome,
      desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(chrome_opts)
    )
end

Capybara.javascript_driver = :headless_chrome

Webdrivers.logger.level = :DEBUG output is here https://gist.github.com/IanVaughan/3e0c50d2fa4a60e672b96f6726fbbb8c

capybara (3.30.0)
webdrivers (4.2.0)
selenium-webdriver (3.142.7)

Full stack trace: https://gist.github.com/IanVaughan/09b31613833d965ee4f3b7d1e48fd1e2

The spec I'm running is :

RSpec.feature 'User signup flow', :js do
  scenario 'Visits home page to signup' do
    visit root_path
    new_window = window_opened_by { click_link 'Sign Up', match: :first }
    within_window new_window do
      expect(page).to have_text('New Enquiry', wait: 5)
    end
  end
like image 740
Ian Vaughan Avatar asked Nov 16 '22 18:11

Ian Vaughan


1 Answers

If the timeout is happening during your apps first request, while the apps doing something onetime (compiling assets, etc), then you may need to increase the allowed read timeout

Capybara.register_driver :selenium do |app|
    Capybara::Selenium::Driver.new(
      ...
      timeout: 60 # defaults to 30 IIRC
    )
end
like image 66
Thomas Walpole Avatar answered Dec 30 '22 08:12

Thomas Walpole