Resolving TypeError: WebDriver.__init__() with Selenium 4.10 and Appium

Resolving TypeError: WebDriver.__init__() with Selenium 4.10 and Appium

10 November 2024 Stephan Petzl Leave a comment Tech-Help

If you’re encountering the TypeError: WebDriver.__init__() got an unexpected keyword argument ‘desired_capabilities’ while using Appium with Selenium 4.10, you’re not alone. This issue arises due to recent changes in Selenium’s handling of capabilities. Below, we’ll guide you through the solution to this problem, ensuring your scripts run smoothly.

Understanding the Issue

The error occurs because the desired_capabilities parameter has been removed from the __init__ method in Selenium 4.10. This change requires a new approach to passing capabilities when initializing the WebDriver.

Solution: Adapting to Selenium 4.10 Changes

To resolve this, you need to update your code to use the new method for setting capabilities. Below is a practical example of how you can adjust your code:

Updated Code Example

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)

This example demonstrates how to configure capabilities using the Options class. For detailed documentation, refer to Selenium’s official documentation.

Alternative Workaround

If you prefer not to upgrade immediately, a temporary workaround involves downgrading the Selenium version. Some users have reported success by reverting to Selenium 4.9.0 in conjunction with Appium-Python-Client 2.9.0.

Enhancing Your Testing Workflow

While adapting to these changes, consider exploring tools that can streamline your test automation processes. Our product, Repeato, offers a no-code test automation solution for iOS and Android apps. Unlike traditional tools like Appium, Repeato utilizes AI and computer vision, allowing for faster and more stable test creation and execution. This can be particularly beneficial if you’re looking for a more efficient and reliable testing framework.

For more insights on mobile testing, visit our blog where we share tips and guides to enhance your testing strategies.

Like this article? there’s more where that came from!