简体   繁体   中英

Rails: Capyabra / Selenium Chrome-Driver Settings

I have my Rails-App set up with Capybara . Tests are working fine but I'm getting this error:

2019-05-03 14:51:58 WARN Selenium [DEPRECATION] Selenium::WebDriver::Chrome#driver_path= is deprecated. Use Selenium::WebDriver::Chrome::Service#driver_path= instead.

Gemfile

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

test_helper.rb (with or without the disabled lines makes no difference)

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)

require 'capybara/rspec'
require 'rspec/rails'
require 'capybara/rails'

RSpec.configure do |config|
  # Capybara.register_driver :chrome do |app|
  #   Capybara::Selenium::Driver.new app, browser: :chrome,
  #                                  options: Selenium::WebDriver::Chrome::Options.new(args: %w[headless disable-gpu])
  # end
  # Capybara.javascript_driver = :chrome
  config.expect_with :rspec do |expectations|
    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  end
  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
  end
  config.shared_context_metadata_behavior = :apply_to_host_groups
  Kernel.srand config.seed
end

Any ideas?

It is not an error,it is a deprecation warning.

The gem chromedriver-helper is deprecated

NOTICE: This gem is out of support as of 2019-03-31 Please use https://github.com/titusfortner/webdrivers instead. See https://github.com/flavorjones/chromedriver-helper/issues/83 for details.

In you gemfile:

group :test do
     gem 'webdrivers', '~> 3.0'
end

group :development, :test do
    gem 'capybara'
end

I'll suggest you to move capybara in the development and test's group, and also update it, if is possible.

this worked for me. Since the gem is deprecated, I just uninstalled the gem

 gem uninstall chromedriver-helper

then remove it from your gem file and run:

bundle update

after that, add the webdriver gem in-place, and bundle install

gem 'webdrivers', '~> 4.0'

bundle install

the warnings should be gone

I had this concern when working on a Rails 6 application in Ubuntu 20.04 .

The issue is that the chrome-helper gem is deprecated. Its last version was 2.1.1 in March 24, 2019.

Here's how I fixed it :

Simply replace the chrome-helper gem with the webdrivers gem in your Gemfile :

So instead of this:

group :test do
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  gem 'chromedriver-helper'
end

You will have this:

group :test do
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  gem 'webdrivers'
end

Then install the gem using:

bundle install

This will update your Gemfile.lock will the webdrivers gem and remove the chrome-helper gem from it as well.

That's all.

I hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM