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

Open Application not working with Selenium 4.10+ (unexpected keyword argument 'desired_capabilities') #404

Open
gucsantana opened this issue Oct 27, 2023 · 2 comments

Comments

@gucsantana
Copy link

My test suite has been working just fine until now, but since upgrading to packages robotframework-appiumlibrary=2.0.0, Selenium=4.14.0 and appium-python-client=3.1.0, currently the latest, the Open Application keyword throws the following error:

Error installing app: TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

Selenium 4.10+ has fully deprecated the 'desired_capabilities' arguments, using 'options' instead. appium-python-client has already made the jump to remove the deprecated arguments from all calls, but when I inspect the appium webdriver at appiumlibrary's _applicationmanagement.py -> open_application, I still see an older build of the webdriver from appium-python-client, that still passes the deprecated arguments, causing a crash from what I can tell. Perhaps an outdated reference, or issue with the version requirements?

If I am doing something wrong on my end, please let me know, too. Thank you.

@pandabat
Copy link

I have also recently come across this issue using the following combination of packages:

robotframework 6.1.1
robotframework-appiumlibrary 2.0.0
robotframework-pythonlibcore 4.3.0
robotframework-seleniumlibrary 6.2.0
robotframework-sshlibrary 3.8.0
selenium 4.15.2

I am using Appium 2.2.2 and uiautomator2@2.34.1 (although issue also seems to occur with appium beta 2.01)

When attempting to run the Open Application keyword with the regular necessary values , it fails with the following:

TypeError: WebDriver.init() got an unexpected keyword argument 'desired_capabilities'

From robot debug.txt:

20231127 21:21:39.371 - FAIL - No application is open
20231127 21:21:39.372 - DEBUG - Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/AppiumLibrary/keywords/keywordgroup.py", line 16, in _run_on_failure_decorator
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/AppiumLibrary/keywords/_applicationmanagement.py", line 60, in open_application
    application = webdriver.Remote(str(remote_url), options=desired_caps, strict_ssl=strict_ssl)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/appium/webdriver/webdriver.py", line 230, in __init__
    super().__init__(
TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/AppiumLibrary/keywords/keywordgroup.py", line 21, in _run_on_failure_decorator
    raise err
  File "/usr/local/lib/python3.11/site-packages/AppiumLibrary/keywords/keywordgroup.py", line 16, in _run_on_failure_decorator
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/AppiumLibrary/keywords/_applicationmanagement.py", line 377, in get_contexts
    print(self._current_application().contexts)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/AppiumLibrary/keywords/_applicationmanagement.py", line 469, in _current_application
    raise RuntimeError('No application is open')
RuntimeError: No application is open

A workaround for now is to downgrade selenium by running: pip install selenium==4.9.1

Seems to relate to:

https://discuss.appium.io/t/getting-typeerror-webdriver-init-got-an-unexpected-keyword-argument-desired-capabilities-when-using-appium-with-selenium-4-10/39386/3

https://github.com/appium/python-client/pull/879

Oddly this only seems to affect me running on a Fedora 38 machine - a Fedora 39 machine that reports itself as running the same libraries/package combination as above does not appear to run into the same issue for reasons that am yet to figure out! The only obvious relevant difference (aside from OS version) is that Python 3.11.6 is on the F38 machine while the F39 machine is running python 3.12.0

@pandabat
Copy link

Made some progress with this, I think.

Certainly it seems that if upgrading robot libraries with pip then perhaps all dependencies/linked libraries are not always upgraded as you might expect.

I believe that the issue here might be linked to Appium-Python-Client which gets installed when installing robotframework-appiumlibrary. When checking for upgrades on robotframework-appiumlibrary using pip, the Appium-Python-Client stayed on v2.7.1 .... BUT if I removed all related libraries/packages with pip (e.g. pip uninstall -y robotframework robotframework-appiumlibrary selenium appium-python-client decorator wheel ) and then re-installed freshly (e.g. pip install -U wheel; pip install -U robotframework-appiumlibrary) then I found that Appium-Python-Client was up to version 3.1.0 and there seems to be links between Appium-Python-Client versions and support for various selenium versions.

Now I am able to run robotframework-appiumlibrary with the selenium version that it pulls in itself (4.15.2) when installing freshly so give that a try and see if it helps.

pip list | grep -E -i 'robotframework|selenium|appium'
Appium-Python-Client           3.1.0
robotframework                 6.1.1
robotframework-appiumlibrary   2.0.0
selenium                       4.15.2

Why simply updating using pip doesn't do this automatically? I am not sure (someone else can probably explain) but a fresh install of the pip libraries/packages seems to have worked for me in relation to this issue anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants