一.简介
uiautomator2是一个python库,用于Android的UI自动化测试,其底层基于Google uiautomator,Google提供的uiautomator库可以获取屏幕上任意一个APP的任意一个控件属性,并对其进行任意操作
二.安装
1. 安装uiautomator2
pip install --upgrade --pre uiautomator2
2.如果你需要用到截图,安装pillow
pip install pillow
3.手机USB线与电脑连接,将关联的守护进程部署到设备电脑连接上一个手机或多个手机,确保adb已经添加到环境变量中,执行下面的命令会自动安装本库所需要的设备端程序:uiautomator-server,atx-agent,openstf / minicap,openstf / minitouch
# init就是所有USB连接电脑的手机上都安装uiautomator2
python -m uiautomator2 init
# 指定手机安装uiautomator2, 用 --mirror
python -m uiautomator2 init --mirror -