uiautomatorviewer定位App元素

这个工具是Android SDK自带的,

日常的工作中经常要使用的,

在C:Androidsdk oolsin目录下:

双击之,

请注意,

我一般选择第一个机器人小图标Device Screenshot,

而不是第二个Device Screenshot with Compressed Hierarchy,

因为第二个是具有压缩层次结构的设备截图,

有可能不准确;

首次启动会报错:

Unable to connect to adb. Check if adb is installed correctly.

怎么解决呢?

关闭之,

打开uiautomatorviewer.bat文件,

修改最后一行:

%prog_dir%

 改为:

C:Androidsdkplatform-tools

并保存

再次打开uiautomatorviewer:

对应关系:

text                     find_element_by_android_uiautomator("new UiSelector().text("文字")")
resource-id         find_element_by_id
class                   find_element_by_class_name
content-desc      find_element_by_accessibility_id

原文地址:https://www.cnblogs.com/yjlch1016/p/8514524.html