Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default driver issues a warning #2511

Closed
dorianmariecom opened this issue Nov 21, 2021 · 11 comments
Closed

Default driver issues a warning #2511

dorianmariecom opened this issue Nov 21, 2021 · 11 comments

Comments

@dorianmariecom
Copy link

Meta

Capybara Version: 3.36.0
Driver Information (and browser if relevant): Chrome Version 96.0.4664.55 (Official Build) (x86_64)

Expected Behavior

No warnings

Actual Behavior

2021-11-21 15:58:23 WARN Selenium [DEPRECATION] [:browser_options] :options as a parameter for driver initialization is deprecated. Use :capabilities with an Array of value capabilities/options if necessary instead.

Steps to reproduce

I'm using the default driver, nothing special, selenium-webdriver (4.0.3) (maybe it's on selenium-webdriver gem, not sure)

@twalpole
Copy link
Member

Selenium changed in v4 - If you need the warning gone immediately please register your own driver config, or I'll look at getting this updated for the next release of Capybara

@dorianmariecom
Copy link
Author

thanks

@ryanb
Copy link

ryanb commented Dec 4, 2021

Here's what I did to update my registered driver (changed options to capabilities with array).

# Before
Capybara.register_driver :chrome_headless do |app|
  Capybara::Selenium::Driver.new app,
    browser: :chrome,
    clear_session_storage: true,
    clear_local_storage: true,
    options: Selenium::WebDriver::Chrome::Options.new(
      args: %w[headless disable-gpu no-sandbox window-size=1024,768],
    )
end

# After
Capybara.register_driver :chrome_headless do |app|
  Capybara::Selenium::Driver.new app,
    browser: :chrome,
    clear_session_storage: true,
    clear_local_storage: true,
    capabilities: [Selenium::WebDriver::Chrome::Options.new(
      args: %w[headless disable-gpu no-sandbox window-size=1024,768],
    )]
end

@twalpole
Copy link
Member

Should be fixed via a958240

@dorianmariecom
Copy link
Author

thanks

@jrochkind
Copy link

jrochkind commented Jan 10, 2022

Thanks! I was trying to figure out where this deprecation warning had started coming from in my build too.

I'm not using the "default driver", but am doing Capybara.javascript_driver = :selenium_chrome

Updating from selenium-webdriver 3.142.7 to 4.1.0 made this warning start showing up.

Confirmed that using capybara master branch at a958240 made warning go away.

@twalpole , is there any chance of a capybara patch release including a958240, so we can avoid the warning while updating selenium, without having to do a local custom driver registration?

@twalpole
Copy link
Member

@jrochkind Not sure when I’ll have time to do a release, there’s a few other things I need to finish up first. Run master, or create a custom registration if the warning is important to you. Personally I have projects that are running tests with the warning, since it’s a warning, not an error, and it’s in test code not production

@jrochkind
Copy link

jrochkind commented Jan 11, 2022

OK, thanks @twalpole !

If anyone wants to temporarily suppress the deprecation warning until the next capybara release is out, while using Selenium 4.1, turns out selenium-webdrivers actually gives you a fairly targeted way to do it:

Selenium::WebDriver.logger.ignore(:browser_options)

(I just don't like it showing up in my build output in the middle of rspec example output, which is how it shows up for me. Could hypothetically cause problems for automation trying to use that output, although I admit I don't actually have any of that at the moment. I just like keeping things clean when I update my dependencies).

@gtekle
Copy link

gtekle commented May 10, 2022

Here's what I did to update my registered driver.

# Before
Capybara.register_driver :chrome_headless do |app|
  Capybara::Selenium::Driver.new app,
    browser: :chrome,
    clear_session_storage: true,
    clear_local_storage: true,
    options: Selenium::WebDriver::Chrome::Options.new(
      args: %w[headless disable-gpu no-sandbox window-size=1024,768],
    )
end

# After
Capybara.register_driver :chrome_headless do |app|
  Capybara::Selenium::Driver.new app,
    browser: :chrome,
    clear_session_storage: true,
    clear_local_storage: true,
    capabilities: [Selenium::WebDriver::Chrome::Options.new(
      args: %w[headless disable-gpu no-sandbox window-size=1024,768],
    )]
end

In May 2022, copy pasting the After part into my rails_helper.rb helped me avoid the deprecation warning.
Thanks 🙏

@jrochkind
Copy link

The fix in question should be included in Capybara 3.73.0 (released May 7 2022) and subsequent, so should not require special configuration to silence deprecation any longer.

@moveson
Copy link

moveson commented Mar 1, 2023

The fix in question should be included in Capybara 3.73.0 (released May 7 2022) and subsequent, so should not require special configuration to silence deprecation any longer.

Note: The version number referenced above should be Capybara 3.37.0 (not 3.73.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants