uiautomator2 环境搭建

327 阅读1分钟

一、安装ADB

下载ADB
   Windows版本:https://dl.google.com/android/repository/platform-tools-latest-windows.zip
   Mac版本:https://dl.google.com/android/repository/platform-tools-latest-windows.zip
   Linux版本:https://dl.google.com/android/repository/platform-tools-latest-linux.zip
下载完成后,解压到任意文件夹。配置环境变量。

连接逍遥模拟器 adb connect 127.0.0.1:21503

查看当前连接的设备,已连接的设备会显示出来 adb devices

查看设备号 adb get-serialno

杀死当前adb服务 adb kill-server

杀掉后重启 adb start-serve

二、安装python的uiautomator2库

pip install -U uiautomator2

如果安装速度慢可以更改为国内镜像源,再次安装

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

三、安装atx-agent

这一步的目的是从github上下载atx-agent,推送到手机,作为服务端。需要确认ADB是否连接到了模拟器/手机,

python -m uiautomator2 init

模拟器/手机上出现下方图标表示成功。

QQ截图20230315135553.png

四、安装 weditor

pip install -U weditor

如果下载报错可以选择老版本下载 pip install -U weditor==0.6.3

命令行执行 weditor 会自动打开浏览器,输入 设备的IP 或者 序列号( 序列号可以通过 adb devices 命令查看得到),然后点击 Connect