UIAutomator 和 UIAutomator2 有什么区别。为什么要切换到 UIAutomator2?

What is the difference between UIAutomator and UIAutomator2. Why should I switch to UIAutomator2?

我目前正在使用 UIAutomator2,但我不确定它在 UIAutomator 之上还提供了哪些其他功能。我将 Appium 与 UIAutomator2 结合使用,没有遇到任何挑战,但我想利用 UIAutomator2 中引入的一些新功能(如果有的话)。

UiAutomator2 是 Appium 社区对 Google UiAutomator 的自定义实现,它主要修复了原始 UiAutomator 中的现有问题以及 stabilise/speedup 与 UI 元素的交互:来自我自己的测量测试 运行 Android 6/UiAutomator 2 平均 20-30% 比 Android 5.1/UiAutomator

上的相同速度快

Android 6 开始,Appium 仅支持 UiAutomator2,所以基本上没有选择去使用旧的易碎的 UiAutomator和社区不支持它,所以如果 smth 不能与 UiAutomator 一起工作 -> 由你来解决它。

实际上自定义功能并不多,但您可以尝试使用 some of capabilities and for sure read release notes appium,因为它们通常会显示最近 UiAutomator2 版本中的新功能,例如Speed up screenshot logic in UiAutomator2