使用uiautomator2和adb shell模拟android系统中的点击事件
文章目录[隐藏]
1.首先创建一个模拟器

2.android模拟器中安装atx-agent
2.1下载atx-agent,选对版本
由于我的模拟器是arm64,所以我选择了arm64的版本

2.2安装并启动atx-agent
% adb push atx-agent /data/local/tmp
atx-agent: 1 file pushed, 0 skipped. 206.6 MB/s (10092696 bytes in 0.047s)
% adb shell chmod 755 /data/local/tmp/atx-agent
% adb shell /data/local/tmp/atx-agent server -d
time="2024-07-25T09:28:24+08:00" level=info msg="run atx-agent in background"
time="2024-07-25T09:28:24+08:00" level=info msg="atx-agent listening on :7912"
3.安装weditor
我的环境
% python3 --version
Python 3.8.7
% pip3 --version
pip 20.2.3 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
安装
% pip install -U weditor
查看是否安装成功
weditor --help
启动
weditor

4.adb测试模拟点击

确保模拟器是当前页面

adb 触发
adb shell input tap x y

5.python代码模拟点击
恢复andriod到首页

修改代码,模拟触发,运行

运行后进到了app中

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。
一条评论
ailibb
优秀,很有用