throwthedays
throwthedays

Reputation: 159

Capybara with Selenium taking too long to load page resulting in Net::ReadTimeout error

I am currently running capybara specs that test different functionality of an app. When running my specs, it appears that the page is not being reached fast enough to test. I have three specs currently, and it takes 9 minutes to end up having them all fail with this same error. Here is the result of running the specs

Randomized with seed 38457
Capybara starting Puma...
* Version 3.11.4 , codename: Love Song
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:50109
FFF

Failures:

1) Successful source is created
 Got 0 failures and 2 other errors:

 1.1) Failure/Error: visit ('/clients/new')

      Net::ReadTimeout:
        Net::ReadTimeout
      # ./spec/qa/variables.rb:12:in `login_user'
      # ./spec/qa/successful_source_spec.rb:7:in `block in (root)'

 1.2) Failure/Error: @io.to_io.wait_readable(@read_timeout) or raise Net::ReadTimeout

      Net::ReadTimeout:
        Net::ReadTimeout

Also note that I am using selenium with chrome headless. Is there anything I can do to have the page load faster so that I can test? This is also the first time these specs are being run.

Upvotes: 0

Views: 1188

Answers (1)

throwthedays
throwthedays

Reputation: 159

I decided to go with a quick fix for this problem. It turns out that the rails server was not connecting to the page fast enough before the test would time out. I decided to change the default wait time in the spec_helper.rb to 120 seconds. It will take a lot longer the first time you run the specs, but they eventually will connect and run smoothly from then on. I do not think this is best practice, but it does provide a quick fix to begin testing your specs.

Upvotes: 1

Related Questions