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

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

Closed
RYenike opened this issue Sep 29, 2023 · 11 comments
Closed

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

RYenike opened this issue Sep 29, 2023 · 11 comments

Comments

@RYenike
Copy link

RYenike commented Sep 29, 2023

The problem

Unable to initialize appium driver.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.22.3
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: Windows 11
  • Node.js version (unless using Appium.app|exe): 18.18.0
  • Mobile platform/version under test: Android 12
  • Real device or emulator/simulator:Real Device
  • Appium CLI or Appium.app|exe: Appium.applexe
  • Appium - Python -Client - 2.11.1
  • Selenium - 4.7.2

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
Copy link
Member

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
Copy link

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
Copy link
Author

RYenike commented Oct 3, 2023

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

@RYenike RYenike closed this as completed Oct 3, 2023
@denji-glitch
Copy link

Can you share me the solution

@Rexze001
Copy link

@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
Copy link

MauricioJacaraci commented Oct 21, 2023

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
Copy link
Member

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
Copy link

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

@MauricioJacaraci
Copy link

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

@NaveenKum07
Copy link

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

@dron4ik86
Copy link

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)

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

No branches or pull requests

9 participants