如何将UI Automator转储用于动态屏幕

时间:2018-08-11 11:39:35

标签: appium uiautomator

我们正在尝试自动化android屏幕,其中有一个进度条,该进度条每秒钟更新一次。我们的框架使用adb shell uiautomator dump检索UI转储,以获取UI层次结构布局,然后解析xml以采取进一步的操作。我们注意到,对于上述屏幕,我们无法获取转储,并且以上命令报告错误“无法获取空闲状态”。

在同一屏幕上,我们尝试使用appium并且appium能够检索UI上的元素。 appium如何能够检索信息,而UI Automator无法检索?我们现在不希望将appium作为工具集成到我们的框架中,而是希望使用ui automator dump本身。有办法解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

问题是Appium有2个Android驱动程序: AndroidDriver UIAutomator2Driver (对于Android 5 +)

第二个是UIAutomator的自定义客户端-服务器实现

https://github.com/appium/appium-uiautomator2-server

https://github.com/appium/appium-uiautomator2-driver

因此,它的字面意思是“ Appium不再按原样使用UIAutomator”。

Google不再支持UIAutomator(最新版本为 july 2017 ),而支持 Espresso

检查服务器部分的代码,您将了解到UIAutomator2 Appium会覆盖很多原始的UIAutomator东西,以解决您所描述的问题以及更多其他问题。 如果您不想使用Appium,您仍然可以重用 UIAutomator2 Server ,或者至少在此基础上编写自定义框架并解决原始UiAutomator的问题。

相关问题