openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.38k stars 1.37k forks source link

HTTP request failed: 404 Client Error: Not Found for url: http://127.0.0.1:32977/jsonrpc/0 #1016

Closed felipegetulio closed 1 month ago

felipegetulio commented 1 month ago

Hi,

I'm having some issues regarding taking an action in the screen. Here are the information about my device: {'serial': 'NKYR2D0327', 'sdk': 33, 'brand': 'motorola', 'model': 'motorola edge 20 lite', 'arch': 'arm64-v8a', 'version': 13}

uiautomator2 version: 3.2.1

Here is the snippet I'm trying to run:

import uiautomator2 as u2
BARCODE = "NKYR2D0327"
device = u2.connect(BARCODE)

print(device.dump_hierarchy())

The error is the following

Traceback (most recent call last):
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/core.py", line 105, in _http_request
    r.raise_for_status()
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://127.0.0.1:32977/jsonrpc/0
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/core.py", line 268, in jsonrpc_call
    return _jsonrpc_call(self._dev, method, params, timeout, self._debug)
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/core.py", line 130, in _jsonrpc_call
    r = _http_request(dev, "POST", "/jsonrpc/0", payload, timeout=timeout, print_request=print_request)
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/core.py", line 115, in _http_request
    raise HTTPError(f"HTTP request failed: {e}") from e
uiautomator2.exceptions.HTTPError: HTTP request failed: 404 Client Error: Not Found for url: http://127.0.0.1:32977/jsonrpc/0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/core.py", line 105, in _http_request
    r.raise_for_status()
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://127.0.0.1:32977/jsonrpc/0
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/getulio/.local/share/JetBrains/Toolbox/apps/pycharm-community/plugins/python-ce/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 5, in <module>
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/__init__.py", line 278, in dump_hierarchy
    content = self._do_dump_hierarchy(compressed, max_depth)
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/retry/api.py", line 73, in retry_decorator
    return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/retry/api.py", line 33, in __retry_internal
    return f()
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/__init__.py", line 293, in _do_dump_hierarchy
    content = self.jsonrpc.dumpWindowHierarchy(compressed, max_depth)
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/__init__.py", line 185, in __call__
    return self.server.jsonrpc_call(self.method, params, http_timeout)
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/core.py", line 273, in jsonrpc_call
    return _jsonrpc_call(self._dev, method, params, timeout, self._debug)
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/core.py", line 130, in _jsonrpc_call
    r = _http_request(dev, "POST", "/jsonrpc/0", payload, timeout=timeout, print_request=print_request)
  File "/home/getulio/Dev/venvs/common/lib/python3.10/site-packages/uiautomator2/core.py", line 115, in _http_request
    raise HTTPError(f"HTTP request failed: {e}") from e
uiautomator2.exceptions.HTTPError: HTTP request failed: 404 Client Error: Not Found for url: http://127.0.0.1:32977/jsonrpc/0

Can someone help me with that?