How to solve uiaotomator tool positioning error

In use uiaotomator tool positioning element process, often will pop up an error, screenshots fail, causing the element can not be located, when faced with this problem, the solution is as follows:

Method One: Unplug the phone usb connection, reconnect the phone

Method Two: adb kill the cell phone service, restart service

  (1) win + R input cmd open command window

    

  ( 2 ) the input command adb kill-server kill Service  

  

  ( 3 ) command input adb start-server Restart Service

   

Method three: uiaotomator , appium two tools often conflict, it can be shut down appium the tool, then use uiaotomator screenshot positioning

       

  

Method four: Perform adb command to save the screenshot

  (1) New uiauto any directory .txt files (disk directory Example D)  

  

 

  (2) Open uiauto file type the following, save

  adb shell uiautomator dump /sdcard/app.uix
  adb pull /sdcard/app.uix ./app-screenshot.uix
  adb shell screencap -p /sdcard/app.png
  adb pull /sdcard/app.png ./app-screenshot.png  

  

  (3)uiauto.txt文件重命名为uiauto.bat

    
  (4)手机操作到指定页面,点击uiauto.bat进行截图(截图成功后会多2个文件,分别是png、uix格式)

  

  (5)uiaotomator工具打开刚生成的2文件,即可定位元素

 

   

  

  

   

   

 

   

 

方法五:若方法一、二、三、四均无效,那么恭喜你,可以换个定位工具定位啦(换appium自带定位工具定位),使用方法如下:

  (1)appium运行界面,打开inspector server:

  

  (2)设置手机&app连接属性:

  

  (3)刷新页面,定位内嵌H5页面元素  

  

 

转载于:https://www.cnblogs.com/mini-monkey/p/11085333.html

Guess you like

Origin blog.csdn.net/weixin_34319640/article/details/94480734