python-client icon indicating copy to clipboard operation
python-client copied to clipboard

AttributeError: 'NoneType' object has no attribute 'ca_certs' and no __dict__ for setting new attributes

Open GitAmi55 opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Appium Version

Appium v2.17.1

Appium Host Type

Command Line

Are you using Appium components not maintained by the Appium team?

No response

Is this issue reproducible using the latest components?

  • [x] I confirm the issue is still reproducible with the latest component versions

Current Behavior

I am unable to run my appium tests as it fails to open the application [ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No application is open AttributeError: 'NoneType' object has no attribute 'ca_certs' and no __dict__ for setting new attributes

I have started the appium server and my device is connected, which can be listed in ADB. However when I run the suite, the tests fails. There are no appium logs to share as it fails.

SInce it looked to me as cert error, I tried to add export

SSL_CERT_FILE=/opt/homebrew/lib/python3.12/site-packages/certifi/cacert.pem

However, that did not change anything. I tried to DEBuG the log file and found this:

File "/opt/homebrew/lib/python3.13/site-packages/AppiumLibrary/keywords/keywordgroup.py", line 16, in _run_on_failure_decorator return method(*args, **kwargs) File "/opt/homebrew/lib/python3.13/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 "/opt/homebrew/lib/python3.13/site-packages/appium/webdriver/webdriver.py", line 223, in __init__ AppiumConnection.set_certificate_bundle_path(None) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/opt/homebrew/Cellar/robot-framework/7.2.2/libexec/lib/python3.13/site-packages/selenium/webdriver/remote/remote_connection.py", line 238, in set_certificate_bundle_path cls._client_config.ca_certs = path ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'ca_certs' and no __dict__ for setting new attributes During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/homebrew/lib/python3.13/site-packages/decorator.py", line 235, in fun return caller(func, *(extras + args), **kw) File "/opt/homebrew/lib/python3.13/site-packages/AppiumLibrary/keywords/keywordgroup.py", line 21, in _run_on_failure_decorator raise err File "/opt/homebrew/lib/python3.13/site-packages/AppiumLibrary/keywords/keywordgroup.py", line 16, in _run_on_failure_decorator return method(*args, **kwargs) File "/opt/homebrew/lib/python3.13/site-packages/AppiumLibrary/keywords/_screenshot.py", line 34, in capture_page_screenshot base64_screenshot = self._current_application().get_screenshot_as_base64() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/opt/homebrew/lib/python3.13/site-packages/AppiumLibrary/keywords/_applicationmanagement.py", line 469, in _current_application raise RuntimeError('No application is open') RuntimeError: No application is open |  

how can we fix this issue? Thanks!

Expected Behavior

Appium tests should run successfully and be able to OPEN the application.

Appium Log

No response

Environment Details

  • Last component version(s) which did not exhibit the problem:
  • Platform and version of device under test: Android
  • Real device or emulator/simulator: Real device

Minimal Reproducible Example

Python version @3.12 Appium-Python-Client 3.2.1 certifi 2025.1.31 cffi 1.17.1 cx_Oracle 8.3.0 decorator 5.2.1 deprecation 2.1.0 opencv-python 4.11.0.86 oracledb 3.1.0 pillow 11.1.0 pip 25.0.1 postappiumlibrary 0.0.15 /Users/shettya/nemo-qs/post-appium-lib pytesseract 0.3.13 robotframework 7.2.2 robotframework-appiumlibrary 2.1.0 robotframework-archivelibrary 0.4.2 robotframework-assertion-engine 3.0.3 robotframework-browser 19.4.0 robotframework-oracledb 2.0.2 robotframework-pythonlibcore 4.4.1 robotframework-requests 0.9.7 robotframework-robocop 6.1.0 robotframework-seleniumlibrary 6.7.1 selenium 4.16.0 setuptools 78.1.0

trio 0.29.0 trio-websocket 0.12.2 typer 0.15.2 typing_extensions 4.13.1 urllib3 2.3.0 wheel 0.45.1 wrapt 1.17.2 wsproto 1.2.0 xgboost 1.6.2

Further Information

No response

GitAmi55 avatar Apr 25 '25 15:04 GitAmi55

It looks like the selenium deps version is higher than expected. The description addresses selenium 4.16.0 but the version doesn't have the code the error had.

packages/appium/webdriver/webdriver.py", line 223, in init AppiumConnection.set_certificate_bundle_path(None) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/opt/homebrew/Cellar/robot-framework/7.2.2/libexec/lib/python3.13/site-packages/selenium/webdriver/remote/remote_connection.py", line 238, in set_certificate_bundle_path cls._client_config.ca_certs = path ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'ca_certs' and no dict for setting new attributes During handling of the above exception, another

4.16.0 expects to be https://github.com/SeleniumHQ/selenium/blob/selenium-4.16.0/py/selenium/webdriver/remote/remote_connection.py

    @classmethod
    def set_certificate_bundle_path(cls, path):
        """Set the path to the certificate bundle to verify connection to
        command executor. Can also be set to None to disable certificate
        validation.

        :Args:
            - path - path of a .pem encoded certificate chain.
        """
        cls._ca_certs = path

is around the error code in 4.16.0. It doesn't have cls._client_config.ca_certs = path which is since selenioum python binding 4.26.0.

Could you make sure the selenium python deps is expected to be 4.16.0 as your description address?

KazuCocoa avatar Apr 25 '25 16:04 KazuCocoa

Otherwise the appium python client should be 4.3.0+ for selenium bindings 4.26.0+ https://github.com/appium/python-client?tab=readme-ov-file#compatibility-matrix

KazuCocoa avatar Apr 25 '25 16:04 KazuCocoa