这篇主要说下如何使用UI Automator Viewer这个工具来定位元素。这个工具是sdk自带的。在sdk安装目录Tools目录下找到uiautomatorviewer.bat并启动它

Python3+Appium学习笔记07-元素定位工具UI Automator Viewer

如果启动闪退,打开cmd把文件扔到cmd中运行,查看具体的报错信息

太高的java jdk版本会报错。目前我使用的是java jdk 8能正常运行。

 

1)打开后的界面如下图

Python3+Appium学习笔记07-元素定位工具UI Automator Viewer

2)然后手机连上电脑,打开想要定位元素的页面。然后点击左上角第二个按钮。就会获取当前手机的屏幕截图

 

Python3+Appium学习笔记07-元素定位工具UI Automator Viewer

3.点击想要定位的元素就可以了,右边会有相应的元素内容

Python3+Appium学习笔记07-元素定位工具UI Automator Viewer

 

还有就是在使用的过程中,经常会报 Error obtaining hierarchy 这个错。

好像是因为appium和UI Automator Viewer都会调用同一个资源。当使用appium代码启动app,不加上关闭的代码。再去使用UI Automator Viewer获取屏幕会报错。把这个app关了。或者appium关了,再去使用UI Automator Viewer就可以了。

 

相关文章:

  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2021-06-02
  • 2021-10-24
  • 2021-09-12
  • 2022-12-23
  • 2021-08-13
猜你喜欢
  • 2021-07-30
  • 2021-06-11
  • 2021-11-15
  • 2021-08-13
  • 2021-05-19
  • 2022-12-23
相关资源
相似解决方案