Retweet 3.2でChromedriver 2.30.477691とgoogle-chrome-beta 60.0.3112.50-1をSelenium-webdriver 3.4.3で使用しています。私の問題は最初の統合テストだけがパスし、ブラウザが閉じられ、他のすべての統合テストは、同じrspecファイルまたは別々のファイルに関係なく失敗します。chromeriver最初のテスト後にクロムを閉じる
フォーカスが設定された単一のテストを実行すると、合格になります。私はヘッドレスオプションの有無を問わず試しましたが、違いはありません。最初のテストの直後にブラウザが閉じていることがわかり、今後のテストで再開しません。
これらのテストはfirefoxを使用して実行されていたので、テストはうまく動作します。ここで
はrails_helper.rbの私のセットアップは、それが配列の最初のテストではない場合は失敗した私のテストの1の
Capybara.register_driver(:headless_chrome) do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: {
binary: "/opt/google/chrome-beta/google-chrome",
args: %w[headless disable-gpu]
}
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: caps
)
end
Capybara.current_driver =:headless_chrome
Capybara.javascript_driver = :headless_chrome
例です。
require "rails_helper"
RSpec.describe "Account Index Page Tests", :type => :feature do
before :each do
admin_sign_in
end
it "Ensure that the index contains one of the default accounts" do
visit "/#/accounts"
expect(find_by_id("heading")).to have_text("Account")
expect(find_by_id("new-btn")).to have_text("New")
expect(find_by_id("name0")).to have_text("Sales")
end
end
上記のテストを2回目のテストとして実行した後、このエラーが発生します。これを逆の順序で実行すると、index_accountsの代わりにもう一方のテストが失敗します。
% rspec spec/integration/accounts/create_accounts_spec.rb spec/integration/accounts/index_accounts_spec.rb
Randomized with seed 30251
.F
Failures:
1) Account Index Page Tests Ensure that the index contains one of the default accounts
Failure/Error: fill_in "Email", with: "[email protected]"
Capybara::ElementNotFound:
Unable to find field "Email"
# ./spec/integration_helpers/login_helper.rb:43:in `admin_sign_in'
# ./spec/integration/accounts/index_accounts_spec.rb:7:in `block (2 levels) in <top (required)>'
Finished in 5.57 seconds (files took 6.2 seconds to load)
2 examples, 1 failure
Failed examples:
rspec ./spec/integration/accounts/index_accounts_spec.rb:10 # Account Index Page Tests Ensure that the index contains one of the default accounts
セレンウェブドライバ2.53.4は、最新のクロムとクロムドライブを使用した1回のテストでも動作することにショックを受けています。最新のセレンウェブドライバにアップグレードしてください。セレン2.53.4に滞在する唯一の理由は、従来のfirefoxのバージョンをテストする必要がある場合です。 –
ちょうどセレン - webdriver 3.4.3にまったく同じ問題にアップグレードされました。 – map7
カピバラを2.14.4 – map7