testcontainers / testcontainers-python

Testcontainers is a Python library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.

Home Page:https://testcontainers-python.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Selenium TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

M4KIF opened this issue · comments

Describe the bug

Using pytest-selenium and test containers, after:

with BrowserWebDriverContainer(_capabilities=DesiredCapabilities.CHROME,_
                                       image="selenium/standalone-chrome") as chrome:
            chrome.start()
            driver = chrome.get_driver()

I receive:
TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities',

It is said, that the variable desired_capabilities is deprecated in current selenium:

@wait_container_is_ready(urllib3.exceptions.HTTPError)
 def _connect(self):
     from selenium import webdriver
     return webdriver.Remote(
         command_executor=(self.get_connection_url()),
         _desired_capabilities_=self.capabilities)

there should be the possibility to use options.

Could I ask for guidance and/or a way of helping with this issue? Or maybe just I am in the wrong, please correct me if that is the case. Thank you.

To Reproduce

Provide a self-contained code snippet that illustrates the bug or unexpected behavior. Ideally, send a Pull Request to illustrate with a test that illustrates the problem.

raise RuntimeError("something went wrong")

Runtime environment

Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using? What is the version of testcontainers-python you are using? You can run the following commands to get the relevant information.

# Get the operating system information (on a unix os).
$ uname -a
# Get the python version.
$ python --version
# Get the docker version and other docker information.
$ docker info
# Get all python packages.
$ pip freeze

Thank you for such a quick answer,

pip freeze:
attrs==23.2.0
black==24.4.2
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
docker==7.0.0
execnet==2.1.1
h11==0.14.0
idna==3.7
iniconfig==2.0.0
Jinja2==3.1.3
MarkupSafe==2.1.5
mypy-extensions==1.0.0
outcome==1.3.0.post0
packaging==24.0
pathspec==0.12.1
platformdirs==4.2.1
pluggy==1.5.0
PySocks==1.7.1
pytest==8.1.1
pytest-base-url==2.1.0
pytest-html==4.1.1
pytest-metadata==3.1.1
pytest-selenium==4.1.0
pytest-variables==3.1.0
pytest-xdist==3.5.0
python-dotenv==1.0.1
requests==2.31.0
selenium==4.20.0
sniffio==1.3.1
sortedcontainers==2.4.0
tenacity==8.2.3
testcontainers==4.4.0
testcontainers-core==0.0.1rc1
testcontainers-selenium==0.0.1rc1
trio==0.25.0
trio-websocket==0.11.1
typing_extensions==4.11.0
urllib3==2.2.1
webdriver-manager==4.0.1
wrapt==1.16.0
wsproto==1.2.0

also, I've didn't saw that the selenium options have the to_capabilities() method. That actually resolves the problem for me. Thank you for the tip with new package naming scheme. I will close the issue, have a good day!

Thank you!