appnium+python无法定位元素的问题

816 阅读1分钟

问题

最近在做微信公众号爬虫的项目,在弄微信手机app自动化的时候发现,当我们使用'uiautomator'定位到某些元素后,指定相应的xpath,会发现程序提示无法定位元素

解决方法

上诉问题出现的原因很有可能是我们手工找的xpath不正确。可以考虑用'uiautomator2'来定位并获取程序的xpath

uiautomator和uiautomator2界面对比

1. uiautomator:

定位“订阅号消息”,uiautomator没有给出xpath

2. uiautomator2:

同样定位“订阅号消息”,uiautomator2给出了xpath

3. uiautomator2安装教程:

这里参考CSDN文章:使用uiautomator2自动化测试app(一)------安装篇