关于python:Android-UI自动化测试Python3

9次阅读

共计 607 个字符,预计需要花费 2 分钟才能阅读完成。

本文仅作为技术学习钻研应用,环境基于 MacOS 10.15.7,Windows 同学可做参考

1. 筹备

1. 安卓设施(本例应用小米 5S)
2.adb
3.Python3
4.UiAutomator2
5.WEditor

2. 工具装置

2.1 adb 装置
2.2 Python3 装置
2.3 UiAutomator2 装置

pip3 install -U uiautomator2

2.4 WEditor 装置

pip3 install -U weditor

3. 开始作业

3.1 连贯设施
记得开启 USB 调试:容许通过 USB 装置利用 容许通过 USB 调试批改权限或模仿点击 这 2 个很重要,截图为小米 5s 参考,其余机型可自行度娘


关上终端执行命令

adb devices


3.2 装置蕴含 httprpc 服务的 apk 到手机
这一步非必须,uiautomator2 v1.3.0 之后的版本,当运行 python 代码 u2.connect()时就会主动推送这些文件

python3 -m uiautomator2 init

3.3 在 Python 交互式编程模式执行以下代码,打印设施信息

import uiautomator2 as u2

d = u2.connect()
print(d.info)


3.4 启动 WEditor
在终端执行一下命令(启动胜利后如下图)

weditor

weditor --shortcut  #Only windows

代码自行丰盛,有意想不到的播种噢

感激:_凌浩雨: Android 自动化测试(Python)

END~~~

正文完
 0