uiautomator2 wifi连接手机


【实施方法】
手机和电脑同时连接到同一个wifi上
1、开启远程adb
#开启远端adb,这一步需要手机通过USB连接到电脑
adb tcpip 5555
#结果如下:restarting in TCP mode port: 5555
#然后断开USB
adb connect 192.168.3.2:5555 
#其中192.168.3.2是手机的局域网IP地址
adb devices
#确认可以看到设备信息

2、通过adb命令启动uiautomator2的agent

db shell /data/local/tmp/atx-agent -d
3、通过uiautomator2脚本连接手机执行用例

import uiautomator2 as u2
d = u2.connect_wifi('192.168.3.2')
print(d.info)
发现可以成功执行

PS:因为有些操作系统上uiautomator2的agent无法自动拉起,所以需要手动通过adb命令拉起


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM