TUiautomator是根据自己需求,参照uiautomator2翻译的kotlin版本,只翻译了常用、需求高的api 翻译的初衷是:
- uiautomator2是python语言开发,自己py语法不熟悉,用起来不是很顺手
- uiautomator2不能单独在手机运行,也就不能手动的开启和关闭脚本运行
- 可以用Uiautomator2开发app,完成自主控制运行
-
安装uiautomator2
pip install --upgrade --pre uiautomator2
-
安装程序到手机 确保adb已经添加到环境变量中,执行下面的命令会自动安装本库所需要的设备端程序:uiautomator-server 、atx-agent、openstf/minicap、openstf/minitouch
# init 所有的已经连接到电脑的设备 python -m uiautomator2 init
有时候init也会出错,请参考手动Init指南
-
【可选】安装weditor (个人推荐安装,因为在写程序时方便测试)
pip install -U weditor
命令行启动
python -m weditor
会自动打开浏览器,输入设备的ip或者序列号,点击Connect即可
以上的配置均可以参考uiautomator2文档