app自动化测试:uiautomator2 连接手机

前提

安装uiautomator2

# uiautomator2 原理:python端运行脚本,往移动端发送HTTP请求;移动端安装atx-agent,然后atx-agent启动uiautomator2服务进行监听,并识别python脚本,转换为uiautomator2的代码;移动设备通过WIFI(同一网段)或USB接收到PC上发来的HTTP请求,执行制定的操作

# 安装 uiautomator2,
pip install -U uiautomator2

# 设备安装atx-agent init就是所有USB连接电脑的手机上都安装uiautomator2
python -m uiautomator2 init

1、确认连接设备(真机/模拟器)

# 查看已连接设备
adb devices

2、 uiautomator2 连接手机

# 方式1: 仅存在1个设备
device = uiautomator2.connect()

# 方式2: 设备id
device = uiautomator2.connect("0123456789ABCDEF")

# 方式3: ip+port
device = uiautomat
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值