Capybara(驱动程序capybara-webkit)零星失败,超过50%的时间成功

时间:2016-01-07 02:01:59

标签: ruby-on-rails ruby capybara integration-testing capybara-webkit

我已经附上了日志,但是,基本上,我整天都在打这个。它在大多数情况下成功,但随后失败,没有可预测的模式。

这些也是非常容易的水豚测试:

$ 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

我不知道是什么原因引起的。我很欣赏任何见解。

parallel /some/binary '{=s/..$//=}'/{} ::: 20131017 20131018

1 个答案:

答案 0 :(得分:3)

像这样的零星错误通常是由规范中的计时问题引起的。通常来自页面占用时间过长的页面上不存在的元素。

我发现修复这些类型错误的最简单方法是将您的期望包装在within block中。然后,您的测试将等到找到用于内部块的选择器,然后才能达到您的期望。

像这样添加一个内部块

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!')