https://github.com/openatx/uiautomator2

安装

Install uiautomator2

# Since uiautomator2 is still under development, you have to add --pre to install the development versionpip install --upgrade --pre uiautomator2# Or you can install directly from github sourcegit clone https://github.com/openatx/uiautomator2pip install -e uiautomator2

测试是否安装成功 uiautomator2 --help

Install weditor (UI Inspector)

因为uiautomator是独占资源,所以当atx运行的时候uiautomatorviewer是不能用的,为了减少atx频繁的启停,我们开发了基于浏览器技术的weditor UI查看器。openatx/weditor

安装方法(备注: 目前最新的稳定版为 0.1.0)

pip install -U weditor

安装好之后,就可以在命令行运行weditor --help 确认是否安装成功了。

Windows系统可以使用命令在桌面创建一个快捷方式 weditor --shortcut

命令行直接输入 weditor 会自动打开浏览器,输入设备的ip或者序列号,点击Connect即可。

具体参考文章:浅谈自动化测试工具python-uiautomator2

Install daemons to a device (Optional)

电脑连接上一个手机或多个手机, 确保adb已经添加到环境变量中,执行下面的命令会自动安装本库所需要的设备端程序:uiautomator-server 、atx-agent、openstf/minicap、openstf/minitouch

用usb连接手机

运行adb devices 查看是否存在设备, 如果没有参考最下面错误

# init 所有的已经连接到电脑的设备python -m uiautomator2 init

有时候init也会出错,请参考手动Init指南

安装提示success即可

【可选】AppetizerIO 所见即所得脚本编辑器

AppetizerIO 提供了对uiautomator2的深度集成,可以图形化管理ATX设备,还有所见即所得脚本编辑器

  • 到网站下载直接打开,首次使用需要注册账号
  • 设备管理 界面里可以检查设备是否正常init,起停atx-agent,抓取atx-agent.log文件
  • 测试脚本调出脚本助手,实时界面同步,点击界面直接插入各种代码,同时支持uiautomator和Appium
  • 视频教程 请戳这里 其他文档在此

之后参考github 学习使用

错误

adb devices没有设备

以小米手机为例, 需要开启开发者选项

打开设置 -> 我的设备 -> 全部参数 -> 连续点击【MIUI版本】选项知道提示【已开启开发者模式】

然后返回设置 -> 更多设置 -> 最下方开发者选项 -> 开启USB调试和USB安装

uiautomator2.exceptions.ConnectError或者RuntimeError: USB device xxx.xxx.xxx.xxx is offline 以及ATX显示ATXAgent Stopped

https://blog.csdn.net/weixin_44045331/article/details/107354853

这是没有开启atxagent, 手动用adb开启

USB连接

adb shellchmod 755 /data/local/tmp/atx-agentdata/local/tmp/atx-agent version  # 查看版本/data/local/tmp/atx-agent server -d  # 启动atx-agent并切换到后台运行

更多相关文章

  1. Android设备信息管理工具类
  2. Android硬件设备检测
  3. 【实用工具】adb检测android设备
  4. Android 开发者学习路线(2020 版本)
  5. android读取usb设备数据
  6. android摄像头,linux摄像头设备,编程
  7. android判断当前设备的支持哪些Feature
  8. 如何通过PC端连接Android设备进行adb调试

随机推荐

  1. android【打电话,收发短信实现】
  2. android JPushInterface.setAlias 报错 j
  3. Android 检查是否安装SD卡
  4. android 注册成功后返回账号和密码到登录
  5. Android文件操作IO技术
  6. Android电池电量更新 - BatteryService
  7. android 文件目录权限
  8. android CTS test
  9. Android LK Bootlaoder启动概览
  10. Android跳转WIFI界面的四种方式