weditor使用详解
1.python环境
2.安装weditor
pip install --index https://mirrors.ustc.edu.cn/pypi/web/simple/ weditor==0.6.4
3.安装urllib3
执行pip3 install urllib3即可,不安装运行weditor会报ModuleNotFoundError: No module named 'urllib3'
4.启动weditor
启动之前需使用adb命令连接设备,以夜神模拟器为例,adb connect 127.0.0.1:62001,adb devices查看是否连接成功,
//启动报错 python -m weditor启动weditor C:\Users\xiaobing>python -m weditor Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "D:\python312\Lib\site-packages\weditor\__main__.py", line 38, in <module> from .web.handlers.page import ( File "D:\python312\Lib\site-packages\weditor\web\handlers\page.py", line 15, in <module> from ..device import connect_device, get_device File "D:\python312\Lib\site-packages\weditor\web\device.py", line 6, in <module> import uiautomator2 as u2 File "D:\python312\Lib\site-packages\uiautomator2\__init__.py", line 40, in <module> import adbutils File "D:\python312\Lib\site-packages\adbutils\__init__.py", line 12, in <module> from ._adb import AdbConnection File "D:\python312\Lib\site-packages\adbutils\_adb.py", line 16, in <module> from adbutils._utils import adb_path File "D:\python312\Lib\site-packages\adbutils\_utils.py", line 17, in <module> from pkg_resources import resource_filename ModuleNotFoundError: No module named 'pkg_resources'
pip install --index https://mirrors.ustc.edu.cn/pypi/web/simple/ setuptools
//重新启动 成功 C:\Users\xiaobing>python -m weditor listening on http://xxx.xxx.xx.xxx:17310 [I 231127 17:03:10 web:2344] 200 GET / (::1) 4.88ms [I 231127 17:03:10 web:2344] 200 GET /cdn.jsdelivr.net/bootstrap/3.3.7/css/bootstrap.min.css (::1) 54.65ms [I 231127 17:03:10 web:2344] 200 GET /cdn.jsdelivr.net/npm/jstree@3.3.8/dist/themes/default/style.min.css (::1) 1.95ms
// 访问listening on http://xxx.xxx.xx.xxx:17310就能正常获取想要的控件,如果app页面变化点击右上角dump hierarchy刷新即可