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

Manager#logs deprecation warning after upgrading to Selenium 4.0 #34

Open
TamasGombos opened this issue Oct 19, 2021 · 14 comments · May be fixed by #38
Open

Manager#logs deprecation warning after upgrading to Selenium 4.0 #34

TamasGombos opened this issue Oct 19, 2021 · 14 comments · May be fixed by #38

Comments

@TamasGombos
Copy link

Hi!

After I updated my gemfiles to use Selenium 4.0, I received a few of these warnings:
2021-10-19 13:48:26 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.

After a few hours of research, I found out that they deprecated the use of Manager:
https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES#L36

The workaround for me was to remove Manage from here:

After I removed it, and reran my tests, the deprecation warnings disappeared, and the console log reports were generated just fine.

I know that currently capybara-chromedriver-logger supports Selenium > 3 and Selenium < 4, but maybe for future versions it would be cool to handle this deprecation warning.

I am glad to help with more information, or anything needed.
Thank you!

@dbalatero
Copy link
Owner

dbalatero commented Oct 21, 2021

Hi @TamasGombos! I see, so they moved everything from .manage up a level and got rid of it?

My issue for patching this is getting a minimal reproduction/environment to test in, so I can ensure I made the right changes. I'd rather not just blindly remove the .manage call, as it might break older clients.

Something like this could work:

def logs(type)
  browser = Capybara.current_session.driver.browser

  if browser.respond_to?(:manage)
    # Support older Selenium versions < 4
    browser.manage.logs.get(type)
  else
    # Support Selenium version 4+
    browser.logs.get(type)
  end
end

Would it be possible for you to help me get a reproduction of this warning? What could I (minimally) do in this repository to start generating this warning?

@TamasGombos
Copy link
Author

TamasGombos commented Oct 21, 2021

Sure!

Thanks for the quick reply!
On our repository, I did not change much, just regenerated the gemfile.lock with running bundle install.

Also upgraded our chromedriver and chrome versions to 94, but I don't think that is related.
The only thing that got changed is Selenium, from version 3.142 to version 4.0 (that requires Ruby > 3.0).

So I would say, just try to update the gems used, run a basic test, that opens a page, and gets a loggable console error, and it should start throwing this error.

I'll try to set up the repository locally, and make an example fail.
Will come back to you as soon as I have it.

@TamasGombos
Copy link
Author

TamasGombos commented Oct 21, 2021

After a bit of messing around with the repository, I was able to make it work, and reproduce the issue I've got.
I needed to make some changes on how we setup the browser, as selenium 4.0 has a slightly different approach.

Two of the tests failed on my setup, but that's probably because of Chrome logging level settings.

I forked the repository, you can find the reproduction branch here:
https://github.com/TamasGombos/capybara-chromedriver-logger/tree/deprecation-warning-selenium-4.0

I also tried the fix you proposed, and it returned the same warning. Selenium 4.0 still supports the 'manage', so the browser responds to it.

You will need: (I used Debian Bullseye)

  • Ruby ~> 3.0
  • Selenium ~> 4.0
  • Bundler ~> 2.2

Run logs without fix:

/usr/bin/ruby2.7 -I/var/lib/gems/2.7.0/gems/rspec-support-3.10.2/lib:/var/lib/gems/2.7.0/gems/rspec-core-3.10.1/lib /var/lib/gems/2.7.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb

collector
2021-10-21 12:42:46 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving no errors
2021-10-21 12:42:46 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving console errors without error raising
2021-10-21 12:42:47 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving console errors with error raising
2021-10-21 12:42:47 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving logs with linebreaks (FAILED - 1)
2021-10-21 12:42:48 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving console info logs (FAILED - 2)
2021-10-21 12:42:49 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  should ignore filtered severity types
2021-10-21 12:42:49 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  should ignore filtered messages

Run logs with branching fix:

/usr/bin/ruby2.7 -I/var/lib/gems/2.7.0/gems/rspec-support-3.10.2/lib:/var/lib/gems/2.7.0/gems/rspec-core-3.10.1/lib /var/lib/gems/2.7.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb

collector
2021-10-21 12:44:26 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving no errors
2021-10-21 12:44:27 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving console errors without error raising
2021-10-21 12:44:27 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving console errors with error raising
2021-10-21 12:44:28 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving logs with linebreaks (FAILED - 1)
2021-10-21 12:44:29 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  receiving console info logs (FAILED - 2)
2021-10-21 12:44:29 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  should ignore filtered severity types
2021-10-21 12:44:30 WARN Selenium [DEPRECATION] Manager#logs is deprecated. Use Chrome::Driver#logs instead.
  should ignore filtered messages

Run logs with .manage removal fix:

/usr/bin/ruby2.7 -I/var/lib/gems/2.7.0/gems/rspec-support-3.10.2/lib:/var/lib/gems/2.7.0/gems/rspec-core-3.10.1/lib /var/lib/gems/2.7.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb

collector
  receiving no errors
  receiving console errors without error raising
  receiving console errors with error raising
  receiving logs with linebreaks (FAILED - 1)
  receiving console info logs (FAILED - 2)
  should ignore filtered severity types
  should ignore filtered messages

@lazebny
Copy link

lazebny commented Jan 7, 2022

Tests produce a lot of noise. Is it possible to fix it?
Screenshot from 2022-01-07 11-35-18

rubendinho added a commit to rubendinho/capybara-chromedriver-logger that referenced this issue Jan 31, 2022
@benschwarz
Copy link

@dbalatero Is there anything I can do to help? Is @rubendinho's patch mergable?

@lazebny
Copy link

lazebny commented Mar 21, 2022

The patch rubendinho@10632e6 works fine for me

@reppiee
Copy link

reppiee commented Jun 15, 2022

Any update to this? Could #38 get merged?

@parhedberg
Copy link

I would also love to get this fixed... Is it going to be in a near future, or can i run the patched version somehow?

@rubendinho
Copy link

rubendinho commented Jun 22, 2022

I would also love to get this fixed... Is it going to be in a near future, or can i run the patched version somehow?

Yes you can run a forked version like this:
gem 'capybara-chromedriver-logger', git: 'https://github.com/rubendinho/capybara-chromedriver-logger'

I recommend making your own fork so your bundle doesn’t break if it’s yanked.

@synth
Copy link

synth commented Aug 28, 2022

Curious what the holdup on this is. This breaks hard in selenium-webdriver v4.4.0 (whereas deprecation warning in v4.1.0).

     Failure/Error:
       Capybara
         .current_session
         .driver.browser
         .manage
         .logs
         .get(type)

     NoMethodError:
       undefined method `logs' for #<Selenium::WebDriver::Manager:0x000000012a978238>

Happy to help or submit a sponsorship to get this across the finish line.

@dbalatero
Copy link
Owner

Sorry, I haven't been using Rails or Capybara for 3 years now and don't have a great test setup here. I'm checking in on #38 - it can be merged, but I don't know the state of things and whether it warrants a hard major version bump since it might be a breaking API change for older clients?

@benschwarz
Copy link

@dbalatero I think a major release will be a good first step.

From what you've said it might also be a good opportunity to re-home the project to another maintainer. What do you think?

@v-kumar
Copy link

v-kumar commented Feb 23, 2023

@dbalatero Can we rehome this repo as @benschwarz requested?

serialworm added a commit to Kindful/capybara-chromedriver-logger that referenced this issue Jul 7, 2023
tf pushed a commit to codevise/capybara-chromedriver-logger that referenced this issue Aug 15, 2023
tf pushed a commit to codevise/capybara-chromedriver-logger that referenced this issue Aug 15, 2023
@tf
Copy link

tf commented Dec 14, 2023

Relevant to make it work with Chrome 120: SeleniumHQ/selenium#13112. TLDR: use --headless=new instead of --headless.

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

Successfully merging a pull request may close this issue.

10 participants