appium / python-client

Python language bindings for Appium
Apache License 2.0
1.69k stars 562 forks source link

'NoneType' object has no attribute 'to_capabilities' is displayed #918

Closed RYenike closed 1 year ago

RYenike commented 1 year ago

The problem

Unable to initialize appium driver.

Environment

Details

Link to Appium Logs

Code To reproduce issue

desired_cap = { "appium:uuid": f"{serial}", "platformName": "Android", "appium:platformVersion" : f"{platform_version}", "appium:deviceName": 'Pixel 4 API 29', "automationName": 'UiAutomator2', "appium:app": f"{apk_Path}" } driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_cap)

ERROR - [2023-09-29_12:53:20] Traceback (most recent call last): File "C:\Users\spolnati\Desktop\local\CD_IQConnect\TestFramework\test_suites\Mobile_application\functional.py", line 94, in verify_joinmeeting driver = desired_caps_android("Daikin", "Mobile Application", self.serial) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\spolnati\Desktop\local\CD_IQConnect\TestFramework\utilities\libraries\lib_functions.py", line 2490, in desired_caps_android driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_cap) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python3115\Lib\site-packages\appium\webdriver\webdriver.py", line 229, in init super().init( File "C:\Python3115\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 185, in init capabilities = options.to_capabilities() ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'to_capabilities'

KazuCocoa commented 1 year ago

I'm not sure what selenium client version your environment had, but you might need to follow options style: https://github.com/appium/python-client?tab=readme-ov-file#usage

This is compatibility matrix: https://github.com/appium/python-client?tab=readme-ov-file#compatibility-matrix

AdrianoSandry commented 1 year ago

RYenike Try this:

from appium.options.android import UiAutomator2Options

desired_cap = { "appium:uuid": f"{serial}", "platformName": "Android", "appium:platformVersion" : f"{platform_version}", "appium:deviceName": 'Pixel 4 API 29', "automationName": 'UiAutomator2', "appium:app": f"{apk_Path}" }

options = UiAutomator2Options().load_capabilities(desired_cap) driver = webdriver.Remote("http://localhost:4723/wd/hub", options=options)

RYenike commented 1 year ago

Issue is fixed after doing pip install requirements.txt might be selenium n appium were not compatible earlier

denji-glitch commented 1 year ago

Can you share me the solution

Rexze001 commented 1 year ago

@denji-glitch I encountered the same issue, but I have resolved it now. The reason was that the version of the 'appium-python-client' package was not compatible with the version of 'selenium'. This is their version compatibility list:

image
MauricioJacaraci commented 1 year ago

Estou encontrando o mesmo problema, já instalei as versões compativeis do cliente appium e selenium e não tem jeito.

Consigo usar tranquilamente o appium desktop, mas não consigo conectar o vscode de jeito nenhum.


AttributeError Traceback (most recent call last) c:\Users\MAURICIO\Desktop\AUTOMAÇÃO-GESTOR\AUTOMAÇÃO_GPS_APP_GESTOR.ipynb Célula 1 line 1 9 caps["appium:appPackage"] = "br.com.hbsis.gestor" 10 caps["appium:appActivity"] = "crc644d5dea12284da3cb.ActivityLogin" ---> 12 driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)

File c:\Users\MAURICIO\Desktop\AUTOMAÇÃO-GESTOR\venv\Lib\site-packages\appium\webdriver\webdriver.py:229, in WebDriver.init(self, command_executor, keep_alive, direct_connection, extensions, strict_ssl, options) 226 if isinstance(command_executor, str): 227 command_executor = AppiumConnection(command_executor, keep_alive=keep_alive) --> 229 super().init( 230 command_executor=command_executor, 231 options=options, 232 ) 234 if hasattr(self, 'command_executor'): 235 self._add_commands()

File c:\Users\MAURICIO\Desktop\AUTOMAÇÃO-GESTOR\venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py:185, in WebDriver.init(self, command_executor, keep_alive, file_detector, options) 183 _ignore_local_proxy = False 184 else: --> 185 capabilities = options.to_capabilities() 186 _ignore_local_proxy = options._ignore_local_proxy 187 self.command_executor = command_executor

AttributeError: 'NoneType' object has no attribute 'to_capabilities'

KazuCocoa commented 1 year ago

Please use Options for caps -> https://github.com/appium/python-client?tab=readme-ov-file#quick-migration-guide-from-v2-to-v3 https://github.com/appium/python-client?tab=readme-ov-file#usage We set deprecation warning messages in past client versions to use Options as well, so if you used appium python lib v2.3.0 or later, the deprecation log might be there.

for the inspector, it looks like we need to update

rahulgupta020 commented 1 year ago

In My case I update Appium-Python-Client. So I downgrade the python version. pip install Appium-Python-Client==2.6.0

MauricioJacaraci commented 1 year ago

Estava usando o java 8 e não tava funcionando, depois que atualizei para o mais recente, tudo funcionou.

NaveenKum07 commented 9 months ago

This worked for me this is due to the selenium and python bindings.

dron4ik86 commented 8 months ago

Try this solution

from appium.webdriver.webdriver import AppiumOptions

appium_options = AppiumOptions()
appium_options.load_capabilities(capabilities)
driver = webdriver.Remote(appium_server_url, options=appium_options)