背景
个人记录,团队分享使用,好记性不如烂笔头~
定位工具
推荐使用顺序:
weditor
>
uiautomatorviewer
>
Appium inspector
三种定位工具
-
中的Python uiautomator2
weditor
- Android SDK 自带的
uiautomatorviewer
-
Appium inspector
三种工具异同点
-
需要配置启动参数,相对较复杂些;Appium inspector
最方便;uiautomatorviewer
-
不能直接定位手机打开的应用,需要重新启动(比如:钉钉每次都要重新登录);Appium inspector
和uiautomatorviewer
不需要,可直接定位;weditor
-
原生不支持 xPath 定位,可二次开发支持;uiautomatorviewer
和Appium inspector
支持;weditor
多种定位工具交替使用时遇到的问题
-
定位时,手机上需要关闭 Appium 的uiautomatorviewer
服务以及 ATX 的io.appium.uiautomator2.server
服务;UIAutomator
- Appium 与 Python uiautomator2 同时使用时需要注意,
与 ATX 的Appium inspector
服务也会存在冲突;UIAutomator
-
启动失败报错: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 inspector
在手机上被卸载了,未卸载干净造成的,解决方法:Appium Settings
重新连接即可(adb uninstall io.appium.settings
同理也可能出现)。io.appium.uiautomator2.server
定位技巧
定位方式推荐顺序:
- 优先使用
定位方式;resourceId
- 其次采用
、text
、description
、相对定位(uiautomator2支持)、组合定位等;className
- 最后采用
定位,结合xPath
、text
等缩短description
长度;xPath
- 无法识别的元素使用坐标定位方式(需要考虑不同分辨率,按照比例封装工具方法)。