android native app 定位工具

1.定位工具

python uiautomator2中的weditor(需要安装)

Android SDK中的uiautomatorviewer (Android SDK home目录下tools\bin)

appium inspector (appium自带)

2.三种工具比较

Appium inspector 需要配置启动参数,相对较复杂些;uiautomatorviewer最方便;

Appium inspector 不能直接定位手机打开的应用,需要重新启动(比如:钉钉每次都要重新登录);uiautomatorviewer和weditor不需要,可直接定位;

uiautomatorviewer原生不支持 xPath 定位,可二次开发支持;Appium inspector和weditor支持;

 

3.多种定位工具交替使用时遇到的问题

1)uiautomatorviewer 定位时,手机上需要关闭 Appium 的io.appium.uiautomator2.server服务以及 ATX 的 UIAutomator服务;

2)Appium 与 Python uiautomator2 同时使用时需要注意,Appium inspector 与 ATX 的 UIAutomator服务也会存在冲突;

3)Appium inspector 启动失败报错:An unknown server side error occurred while processing the command. Original error: Failed to launch Appium Settings app: Condition unmet after 5001 ms. Timing out.),一种原因是Appium Settings在手机上被卸载了,未卸载干净造成的,解决方法:adb uninstall io.appium.settings重新连接即可(io.appium.uiautomator2.server同理也可能出现)。
定位技巧

4.定位方式推荐顺序:

优先使用resourceId定位方式;
其次采用text、description、className、相对定位(uiautomator2支持)、组合定位等;
最后采用xPath定位,结合text、description等缩短 xPath 长度;
无法识别的元素使用坐标定位方式(需要考虑不同分辨率,按照比例封装工具方法)。

 

posted @   mik99  阅读(97)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示