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
运行报错了
我的 python 3.10
为什么呢?是还需要在手机端安装什么软件吗?
我直接在 mac 上使用 adb 操作 xiaomi12 是正常的