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

HTTP Return code is not 200 #925

Closed
ponponon opened this issue Dec 4, 2023 · 2 comments
Closed

HTTP Return code is not 200 #925

ponponon opened this issue Dec 4, 2023 · 2 comments

Comments

@ponponon
Copy link

ponponon commented Dec 4, 2023

import uiautomator2 as u2


ip = '192.168.2.2:40531'
d = u2.connect(ip)  # connect to device
print(d.info)

运行报错了

╰─➤  python -m dev.demo_uiautomator2                                                                                                                                                                                                                               1 ↵
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/ponponon/Desktop/code/work/wechatimagesearch/dev/demo_uiautomator2.py", line 6, in <module>
    print(d.info)
  File "/Users/ponponon/.local/share/virtualenvs/wechatimagesearch-ut6SlEe8/lib/python3.10/site-packages/uiautomator2/__init__.py", line 448, in info
    return self.jsonrpc.deviceInfo(http_timeout=10)
  File "/Users/ponponon/.local/share/virtualenvs/wechatimagesearch-ut6SlEe8/lib/python3.10/site-packages/uiautomator2/__init__.py", line 479, in __call__
    return self.server._jsonrpc_retry_call(self.method, params,
  File "/Users/ponponon/.local/share/virtualenvs/wechatimagesearch-ut6SlEe8/lib/python3.10/site-packages/uiautomator2/__init__.py", line 486, in _jsonrpc_retry_call
    return self._jsonrpc_call(*args, **kwargs)
  File "/Users/ponponon/.local/share/virtualenvs/wechatimagesearch-ut6SlEe8/lib/python3.10/site-packages/uiautomator2/__init__.py", line 525, in _jsonrpc_call
    raise BaseError(data, res.status_code, res.text,
uiautomator2.exceptions.BaseError: ('{"jsonrpc": "2.0", "id": "0e789cc11a8e35f7e50f14e60c91ecce", "method": "deviceInfo", "params": {}}', 503, '', 'HTTP Return code is not 200', '')

我的 python 3.10

➤  pip show uiautomator2                                                                                                                                                                                                                                         1 ↵
Name: uiautomator2
Version: 2.16.25
Summary: Python Wrapper for Google Android UiAutomator2 test tool
Home-page: https://github.com/openatx/uiautomator2
Author: codeskyblue
Author-email: codeskyblue@gmail.com
License: MIT
Location: /Users/ponponon/.local/share/virtualenvs/wechatimagesearch-ut6SlEe8/lib/python3.10/site-packages
Requires: adbutils, cached-property, Deprecated, filelock, logzero, lxml, packaging, Pillow, progress, requests, retry, six, whichcraft
Required-by: 

图片

图片

图片

为什么呢?是还需要在手机端安装什么软件吗?


我直接在 mac 上使用 adb 操作 xiaomi12 是正常的

╭─ponponon@MBP13ARM ~  
╰─➤  adb devices                                        
List of devices attached
192.168.2.2:40531       device

╭─ponponon@MBP13ARM ~  
╰─➤  adb shell input swipe 500 1000 500 2000            
╭─ponponon@MBP13ARM ~  
╰─➤  adb shell am start -n com.tencent.mm/.ui.LauncherUI
Starting: Intent { cmp=com.tencent.mm/.ui.LauncherUI }
Warning: Activity not started, its current task has been brought to the front
@ponponon
Copy link
Author

ponponon commented Dec 4, 2023

问题已解决

需要先执行 python3 -m uiautomator2 init

@codeskyblue
Copy link
Member

fixed

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