uiautomator2的安装与使用

开源项目地址:https://github.com/openatx/uiautomator2

介绍:

  • uiautomator2是做安卓自动化框架,内部封装了一系列的操作安卓app的方法

原理:

  • python端: 运行脚本,并向移动设备发送HTTP请求
  • 移动设备:移动设备上运行了封装了uiautomator2的HTTP服务,解析收到的请求,并转化成uiautomator2的代码。

环境要求:

  • python3.6以上
  • 安卓版本5以上

安装方法:

  1. 安装ui2
pip3 install -U uiautomator2
  1. 安装后验证
import uiautomator2 as u2
d = u2.connect('123456f') # 参数为 deviceid
print(d.info) # 如果有结果输出,表示安装成功
  1. 安装查看元素工具weditor
- 安装方式:pip3 install --pre weditor
- 启动方式:python3 -m weditor

使用方法:

image
image
image

posted @ 2023-01-16 23:00  alisleepy  阅读(228)  评论(0编辑  收藏  举报