1.相关链接:http://blog.csdn.net/fengyang_123456/article/details/62065337

参考文档: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\tools\lib 文件夹中替换掉原来的uiautomatorviewer.jar包。
双击安卓安装目录下的 \android-sdk\tools\uiautomatorviewer.bat 文件,启动lazy-uiautomatorviewer。
2。使用
打开后的uiautomator view如下显示
通过lazy-uiautomatorviewer来获得android元素的xpath
在识别元素时,选择左上角的device screenshot,而不用device screenshot with compressed。第二个是经过压缩后的screenshot,得到xpath也是不全的,通过这个xpath很有可能会识别不到对象。
通过lazy-uiautomatorviewer来获得android元素的xpath
得到xpath 之后就可以通过driver.find_element_by_xpath(”)的方法来操作对象了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-01-25
  • 2021-10-18
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2021-12-18
  • 2021-09-24
  • 2021-10-28
  • 2021-05-28
  • 2022-12-23
  • 2021-11-02
  • 2022-01-22
相关资源
相似解决方案