本文仅作为技术学习钻研应用,环境基于MacOS 10.15.7,Windows同学可做参考
1.筹备
1.安卓设施(本例应用小米5S)
2.adb
3.Python3
4.UiAutomator2
5.WEditor
2.工具装置
2.1 adb 装置
2.2 Python3 装置
2.3 UiAutomator2 装置
pip3 install -U uiautomator2
2.4 WEditor 装置
pip3 install -U weditor
3.开始作业
3.1 连贯设施
记得开启USB调试:容许通过USB装置利用
和容许通过USB调试批改权限或模仿点击
这2个很重要,截图为小米5s参考,其余机型可自行度娘
关上终端执行命令
adb devices
3.2 装置蕴含httprpc服务的apk到手机
这一步非必须,uiautomator2
v1.3.0之后的版本,当运行python代码u2.connect()时就会主动推送这些文件
python3 -m uiautomator2 init
3.3 在Python交互式编程模式执行以下代码,打印设施信息
import uiautomator2 as u2 d = u2.connect() print(d.info)
3.4 启动WEditor
在终端执行一下命令(启动胜利后如下图)
weditor weditor --shortcut #Only windows
代码自行丰盛,有意想不到的播种噢
感激:_凌浩雨: Android 自动化测试(Python)