Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting TypeError: WebDriver.__init__() got an unexpected keyword argument ‘desired_capabilities’ when using Appium with Selenium 4.10

Error: HOOK-ERROR in before_scenario: TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

Hello, we currently cannot run our script together with the latest Selenium 4.10. Is this Appium error or Python error?

Here is the capabilities that we used. We're currently trying to get the capabilities for platformName by targetOS = self.driver.capabilities['platformName'] but we're hit with this error

capabilities = {
    "platformName": "Android",
    "appium:platformVersion": "11.0",
    "appium:deviceName": "emulator-5554",
    "appium:app": "/Users/faithberroya/Downloads/test.apk",
    "appium:automationName": "UiAutomator2",
    "appium:appPackage": "com.test.school.assignment.rc",
    "appium:appActivity": "com.test.school.assignment.ui.SplashActivity"
}

# launch app
context.driver = webdriver.Remote("http://0.0.0.0:4723/wd/hub", capabilities)
# add wait time
context.driver.implicitly_wait(20)
# app
context.app = Application(context.driver)

Current pip list

Appium-Python-Client     2.10.1
behave                   1.2.6
certifi                  2023.5.7
pip                      23.1.1
requests                 2.31.0
selenium                 4.9.0
like image 843
Faith Berroya Avatar asked Dec 06 '25 04:12

Faith Berroya


2 Answers

This is due to changes in selenium 4.10.0: https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e

Changes_in_selenium_4_10_0

Note that desired_capabilities has been removed from the __init__, but there is now another way of passing it in. See https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/#capabilities for the documentation on how to pass in desired capabilities when using selenium 4.10.0 (or newer).

Here's a code snippet on using capabilities in the new version:

from selenium.webdriver.firefox.options import Options as FirefoxOptions
options = FirefoxOptions()
cloud_options = {}
cloud_options['build'] = "build_1"
cloud_options['name'] = "test_abc"
options.set_capability('cloud:options', cloud_options)
driver = webdriver.Remote("http://0.0.0.0:4723/wd/hub", options=options)
like image 187
Michael Mintz Avatar answered Dec 08 '25 16:12

Michael Mintz


I face similar issue. By default Appium python client uses latest selenium release(4.10.0). So i downgraded the version to 4.9.0 with Appium-python-client as 2.9.0 and it worked fine.

like image 40
Essai Avatar answered Dec 08 '25 16:12

Essai