appium--uiautomatorviewer的使用

uiautomatorviewer的使用

uiautomatorviewer也是获取页面元素属性的工具,相比之前介绍的appium desktop来说,方便了很多,appium desktop需要从启动页开始,而uiautomatorviewer不需要。

安装完androidsdk之后,在tools下就有了,我的是wins系统,所以点击uiautomatorviewer.bat就可以打开了

点击之后如果你看到的和我的页面一样,就表示启动成功了

获取元素的属性

前提:我们的电脑已经连接上了我们的手机,打开app的任意一个页面

如果你出现下面错误

  升级uiautomatorviewer,或许是当前页面是动态的,都可能会报这样的错

可以新建一个bat文件,写入如下代码

#!/bin/sh

builddate=`date '+%Y%m%d%H%M'`

adb shell uiautomator dump /sdcard/app.uix
adb pull /sdcard/app.uix ./app${builddate}.uix
#存到E盘的app.uix文件中,在E盘新建一个文本文档改成app.uix
adb shell screencap -p /sdcard/app.png
adb pull /sdcard/app.png ./app${builddate}.png

启动之后就可以截屏,然后使用uiautomatorviewer打开截的图就可以了

原文地址:https://www.cnblogs.com/zouzou-busy/p/11368624.html