一、使用adb 命令 + uiautomator 获取app控件id
1.在E盘根目录下创建app.png文本文件
2.在E盘根目录下创建app.uix文本文件
3.执行以下adb命名:
adb shell uiautomator dump /sdcard/app.uix
adb pull /sdcard/app.uix E:/app.uix
adb shell screencap -p /sdcard/app.png
adb pull /sdcard/app.png E:/app.png
4.运行uiautomatorviewer.bat,导入文件
编辑
编辑
二、为了开发脚本简洁,推荐使用模拟器 + 二次开发后的 uiautomatorviewer.jar 进行快速获取
Lvmama Ui Automator Viewer使用帮助
1,安装准备
-
打开手机模拟器,安装驴妈妈测试App
-
复制LvmamaXmlKit.jar到本地D盘根目录下,打开命令行窗口执行命令:
adb push D:\LvmamaXmlKit.jar /data/local/tmp/
- 打开手机文件管理,到 /data/local/tmp/目录下,检查确保LvmamaXmlKit.jar是否复制到手机中
编辑
- 模拟器中安装ADBKeyBoard.apk并设置设置默认输入法为ADBKeyBoard,并关闭硬件物理键盘。
编辑
5.重命名自己电脑SDK目录的 \android-sdk-windows\tools\lib 下面的uiautomatorviewer.jar==》
uiautomatorviewer.zip。复制共享目录\自动化\个人\autotest_helper\下面的uiautomatorviewer.jar到自己
电脑SDK目录的 \android-sdk-windows\tools\lib 下
6.点击uiautomatorviewer.bat 开启生成代码之旅。
二次开发jar包:二次开发uiautomatorviewer.jar-Java文档类资源-CSDN下载
\