#34675 closed Cleanup/optimization (fixed)

Selenium WebDriver implementation is broken due to update of Selenium

Reported by: Jonathan Weth Owned by: Jonathan Weth
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description

    def create_webdriver(self):
        if self.selenium_hub:
            from selenium import webdriver
    
>           return webdriver.Remote(
                command_executor=self.selenium_hub,
                desired_capabilities=self.get_capability(self.browser),
            )
E           TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

.tox/globalenv/lib/python3.11/site-packages/django/test/selenium.py:92: TypeError

In selenium >= 4.10, desired_capabilities is no longer a valid argument for the constructor of WebDriver. There seem to be other ways to set those capabilities.

https://github.com/django/django/blob/main/django/test/selenium.py#L95
https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e

Change History (8)

comment:1 by Natalia Bidart, 10 months ago

Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization
UI/UX: set

Accepting following data from report and this post. Upgrade options are listed here.

comment:2 by Jonathan Weth, 10 months ago

Owner: changed from nobody to Jonathan Weth
Status: newassigned

comment:3 by Mariusz Felisiak, 10 months ago

I'm not sure why but I cannot reproduce this crash with selenium 4.10.0.

comment:4 by Jonathan Weth, 10 months ago

Has patch: set

in reply to:  3 comment:6 by Jonathan Weth, 10 months ago

Replying to Mariusz Felisiak:

I'm not sure why but I cannot reproduce this crash with selenium 4.10.0.

The bug only occurs if you are using a remote Selenium web driver.

  1. g. with (using docker-selenium)
    ./runtests.py --selenium firefox --selenium-hub http://127.0.0.1:4444/wd/hub --external-host 172.17.0.1
    
Last edited 10 months ago by Natalia Bidart (previous) (diff)

comment:7 by Natalia Bidart, 10 months ago

Reproduced with the given instructions, thanks!

Ran docker-selenium as suggested in https://github.com/SeleniumHQ/docker-selenium#quick-start:

docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-firefox:4.10.0-20230607

And then:

./runtests.py --selenium=firefox --selenium-hub=http://localhost:4444/wd/hub

Errors are:

Traceback (most recent call last):
  File "/usr/lib/python3.11/unittest/suite.py", line 166, in _handleClassSetUp
    setUpClass()
  File "/home/nessita/fellowship/django/django/test/selenium.py", line 115, in setUpClass
    cls.selenium = cls.create_webdriver()
    ^^^^^^^^^^^^^^^^^
  File "/home/nessita/fellowship/django/django/test/selenium.py", line 93, in create_webdriver
    return webdriver.Remote(
    ^^^^^^^^^^^^^^^^^
TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

comment:8 by GitHub <noreply@…>, 10 months ago

Resolution: fixed
Status: assignedclosed

In ecd5a0da:

Fixed #34675 -- Fixed creating remote webdriver for Selenium 4.10.0+.

Note: See TracTickets for help on using tickets.
Back to Top