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

Usage of deprecated desired_capabilities in Selenium Wire #3202

Closed
fgibertoni opened this issue Oct 18, 2024 · 5 comments
Closed

Usage of deprecated desired_capabilities in Selenium Wire #3202

fgibertoni opened this issue Oct 18, 2024 · 5 comments
Labels
external Outside SeleniumBase's scope. / Ask somewhere else. workaround exists You can reach your destination if you do this...

Comments

@fgibertoni
Copy link

Hello everyone!
I am getting a TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities' using latest SeleniumBase version (v4.31.6) when instancing a seleniumbase.Driver object using Selenium Grid and Selenium Wire.

How to reproduce

I am using Python 3.12.3, Selenium Base 4.31.6 and Google Chrome 130.0.6723.58.

Selenium Grid has been successfully started (following docs) with:

seleniumbase download server
seleniumbase grid-hub start
seleniumbase grid-node start

I am connecting to the grid running at http://localhost:4444 with:

driver = Driver(
    headless=True,
    headless2=True,
    use_wire=True,
    no_sandbox=True,
    proxy=proxy_address or None,
    proxy_bypass_list=proxy_address or None,
    browser="chrome",
    servername="127.0.0.1",
    port=4444,
)

I expected to connect to my local instance of Selenium Grid to run some tests and analyze HTTP requests and responses.

Error message

Traceback (most recent call last):
  File "/opt/deploy/analyzers/extract_site.py", line 62, in <module>
    analyze_target(target_url=arguments.target, proxy_address=arguments.proxy_address)
  File "/opt/deploy/analyzers/extract_site.py", line 46, in analyze_target
    driver_wrapper = DriverWrapper(proxy_address=proxy_address)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/deploy/analyzers/driver_wrapper.py", line 38, in __init__
    self.driver: Chrome = self._init_driver()
                          ^^^^^^^^^^^^^^^^^^^
  File "/opt/deploy/analyzers/driver_wrapper.py", line 47, in _init_driver
    driver = Driver(
             ^^^^^^^
  File "/home/user/.local/lib/python3.12/site-packages/seleniumbase/plugins/driver_manager.py", line 782, in Driver
    driver = browser_launcher.get_driver(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.12/site-packages/seleniumbase/core/browser_launcher.py", line 2402, in get_driver
    return get_remote_driver(
           ^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.12/site-packages/seleniumbase/core/browser_launcher.py", line 2759, in get_remote_driver
    driver = webdriver.Remote(
             ^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.12/site-packages/seleniumwire/webdriver.py", line 308, in __init__
    super().__init__(*args, **kwargs)
TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

Analysis

Selenium removed desired_capabilities from version 4.10.0 but Selenium Wire is still using it. Unluckily I don't think they will ever fix the issue as the project is no longer maintained.

During investigations I noticed that in browser_launcher.py there is no way to pass the optional parameter auto_config=False in seleniumwire_options that would prevent the old code from being executed.
Passing this parameter could be a workaround waiting for a more structured solution.


Is there another way to avoid this error or am I missing something here ?
Thank you for your help.

@mdmintz mdmintz added external Outside SeleniumBase's scope. / Ask somewhere else. workaround exists You can reach your destination if you do this... labels Oct 18, 2024
@mdmintz
Copy link
Member

mdmintz commented Oct 18, 2024

Wire Mode isn't compatible with Grid Mode anymore because selenium-wire is unmaintained and archived.

The issues are coming directly from selenium-wire:

You have two options:

  • Use Wire Mode without Grid Mode.
  • Use Grid Mode without Wire Mode.

@mdmintz mdmintz closed this as completed Oct 18, 2024
@fgibertoni
Copy link
Author

Thank you for your answer.
I think this issue should be reported somewhere in the documentation (I was not able to find it).

Also, it should be enough to adapt the old code to avoid usage of the deprecated argument and passing the desired capabilities to the constructor together with auto_config=False to avoid the execution of the deprecated branch of code.
I understand this could be considered a bit messy, but I think that it would be useful to have an official workaround/patch for this issue.
What's your opinion on this proposal? We can also evaluate some other alternatives to have both Grid Mode and Wire Mode working together.

@mdmintz
Copy link
Member

mdmintz commented Oct 21, 2024

This can be the documentation if it wasn't clear:

  • Can't mix Wire Mode with Grid Mode
  • Can't mix UC Mode with Wire Mode
  • Can't mix Grid Mode with UC Mode

If that doesn't work for you, try another repo.

@fgibertoni
Copy link
Author

I apologize if I came across as disrespectful; that was not my intention, I really like this project.

I was just offering to help with this issue and looking to gather your feedback on whether you believe this would be beneficial for the community before I begin working on it 😄

@mdmintz
Copy link
Member

mdmintz commented Oct 21, 2024

@fgibertoni You're welcome to look into it. Given that selenium-wire works by spinning up a local proxy server to collect the additional data, I don't think it would even work via a remote Grid machine. If you were just planning on running a local Grid for the multithreading, then that is unnecessary with the pytest-xdist multithreading system that's already built-in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Outside SeleniumBase's scope. / Ask somewhere else. workaround exists You can reach your destination if you do this...
Projects
None yet
Development

No branches or pull requests

2 participants