I have attached the log, but, basically, I've been fighting this all day. It succeeds the majority of the time, but then randomly fails with no predictable pattern.
These are very easy capybara tests, too:
t.visit '/signup'
t.fill_in 'user_email', :with => email
t.fill_in 'user_password', :with => password
t.fill_in 'user_password_confirmation', :with => password
t.click_on 'Create Login'
expect(page).to have_content('Welcome!')
I have no idea what could cause this. I'd appreciate any insight.
$ repeat 12 {rspec}
Randomized with seed 64607
.WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
....
Finished in 1 minute 6 seconds (files took 1.94 seconds to load)
5 examples, 0 failures
Randomized with seed 64607
Randomized with seed 64579
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
.....
Finished in 1 minute 10.06 seconds (files took 2.16 seconds to load)
5 examples, 0 failures
Randomized with seed 64579
Randomized with seed 19540
.WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
....
Finished in 1 minute 9.6 seconds (files took 2.17 seconds to load)
5 examples, 0 failures
Randomized with seed 19540
Randomized with seed 14891
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
.....
Finished in 1 minute 10.32 seconds (files took 2.27 seconds to load)
5 examples, 0 failures
Randomized with seed 14891
Randomized with seed 18405
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
..F..
Failures:
1) User accounts Creating a new account does proceed with valid information
Failure/Error: expect(page).to have_content('Welcome!')
Capybara::Webkit::NodeNotAttachedError:
Element at 24 no longer present in the DOM
# ./spec/features/create_account_spec.rb:24:in `block (3 levels) in <top (required)>'
Finished in 1 minute 10.47 seconds (files took 2.36 seconds to load)
5 examples, 1 failure
Failed examples:
rspec ./spec/features/create_account_spec.rb:21 # User accounts Creating a new account does proceed with valid information
Randomized with seed 18405
Randomized with seed 44934
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
..F..
Failures:
1) User accounts Creating a new account responds with an error if a password is invalid
Failure/Error: t.visit '/signup'
Capybara::Webkit::TimeoutError:
Request timed out after 30 second(s)
Finished in 1 minute 37.2 seconds (files took 2.14 seconds to load)
5 examples, 1 failure
Failed examples:
rspec ./spec/features/create_account_spec.rb:34 # User accounts Creating a new account responds with an error if a password is invalid
Randomized with seed 44934
Randomized with seed 2418
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
.....
Finished in 1 minute 38.48 seconds (files took 2.22 seconds to load)
5 examples, 0 failures
Randomized with seed 2418
Randomized with seed 62514
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
..F..
Failures:
1) User accounts Creating a new account does proceed with valid information
Failure/Error: expect(page).to have_content('Welcome!')
Capybara::Webkit::NodeNotAttachedError:
Element at 25 no longer present in the DOM
# ./spec/features/create_account_spec.rb:24:in `block (3 levels) in <top (required)>'
Finished in 1 minute 44.84 seconds (files took 2.18 seconds to load)
5 examples, 1 failure
Failed examples:
rspec ./spec/features/create_account_spec.rb:21 # User accounts Creating a new account does proceed with valid information
Randomized with seed 62514
Randomized with seed 61981
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
Request to unknown URL: https://api.stripe.com/v1/tokens?...
To block requests to unknown URLs:
Capybara::Webkit.configure do |config|
config.block_unknown_urls
end
To allow just this URL:
Capybara::Webkit.configure do |config|
config.allow_url("https://api.stripe.com/v1/tokens?key=pk_test_ahWNI8gsTepFWYX9nnO0Kgxv&payment_user_agent=stripe.js/699b119&card[name]=Bob+Tomato&card[number]=42&card[cvc]=567&card[address_zip]=37069&card[exp_month]=1&card[exp_year]=2026&callback=sjsonp1452131002689&_method=POST&_accept_language=en-US")
end
To allow requests to URLs from this host:
Capybara::Webkit.configure do |config|
config.allow_url("api.stripe.com")
end
F....
Failures:
1) User accounts Creating a new account does not proceed if any information is missing
Failure/Error: expect(page).to have_content('This Card Number Looks Invalid')
expected to find text "This Card Number Looks Invalid" in ...
# ./spec/features/create_account_spec.rb:18:in `block (3 levels) in <top (required)>'
Finished in 1 minute 50.89 seconds (files took 2.41 seconds to load)
5 examples, 1 failure
Failed examples:
rspec ./spec/features/create_account_spec.rb:15 # User accounts Creating a new account does not proceed if any information is missing
Randomized with seed 61981
Randomized with seed 55263
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
.....
Finished in 1 minute 27.56 seconds (files took 2.26 seconds to load)
5 examples, 0 failures
Randomized with seed 55263
Randomized with seed 21927
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
.....
Finished in 1 minute 23.52 seconds (files took 2.22 seconds to load)
5 examples, 0 failures
Randomized with seed 21927
Randomized with seed 8605
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.7.
....F
Failures:
1) User accounts Creating a new account does not proceed if any information is missing
Failure/Error: t.visit '/signup'
Capybara::Webkit::TimeoutError:
Request timed out after 30 second(s)
Finished in 1 minute 32.47 seconds (files took 2.02 seconds to load)
5 examples, 1 failure
Failed examples:
rspec ./spec/features/create_account_spec.rb:15 # User accounts Creating a new account does not proceed if any information is missing
Randomized with seed 8605
Sporadic errors like this are typically caused from an a timing problem in your specs. Usually from elements not existing on the page when the page took too long to load.
The easiest way I have found to fix these types of errors is to wrap your expectations in a within block
. Your tests then will actually wait to find that selector used for the within block before proceeding to your expectations.
Add a within block like this
t.visit '/signup'
within "form" do
t.fill_in 'user_email', :with => email
t.fill_in 'user_password', :with => password
t.fill_in 'user_password_confirmation', :with => password
t.click_on 'Create Login'
end
expect(page).to have_content('Welcome!')