app定位器带xpath的 uiautomatorviewer

参考文档:http://blog.csdn.net/kaka1121/article/details/53301517 
在写脚本的过程中,总是遇到标签没有ID或者name等类似的唯一识别属性,为了能识别到这些对象,只能通过xpath了。可是sdk自带的uiautomatorviewer并不能获得xpath。在网上找到一个资源可以自动获取xpath–lazy-uiautomatorviewer. 
jar包下载地址:http://download.csdn.net/detail/kaka1121/9685936; 
源码下载地址:https://github.com/lazytestteam/lazyuiautomatorviewer;

我自己的放在了百度云上

1.下载 
下载好jar包后把uiautomatorviewer.jar拷贝到安卓安装目录下的 
android-sdk oolslib 文件夹中替换掉原来的uiautomatorviewer.jar包。 
双击安卓安装目录下的 android-sdk oolsuiautomatorviewer.bat 文件,启动lazy-uiautomatorviewer。 
2。使用 
打开后的uiautomator view如下显示 
这里写图片描述 
在识别元素时,选择左上角的device screenshot,而不用device screenshot with compressed。第二个是经过压缩后的screenshot,得到xpath也是不全的,通过这个xpath很有可能会识别不到对象。 
这里写图片描述
得到xpath 之后就可以通过driver.find_element_by_xpath(”)的方法来操作对象了。

原文地址:https://www.cnblogs.com/kaibindirver/p/8158280.html