AndroidViewClient 的转储问题:视图刷新过于频繁,无法转储

the dump problem of AndroidViewClient: The views are being refreshed too frequently to dump

我需要使用AndroidViewClient 做一些自动化测试。 在我的代码中,我使用了 ViewClient 的 dump()。但是我经常遇到以下错误:

RuntimeError: The views are being refreshed too frequently to dump.

可以这样加:

ERROR: could not get idle state.

dtmilano(Android 应用程序测试指南的作者)answered a similar problem in this question。他说有uiautomator限制。

但是我的API的号码是19,为什么还有uiautomator限制?我该如何处理这个问题?如何使用waitforidle()?

这是一个 UiAutomator 限制。

正如我在另一个答案中提到的,如果您的设备处于安全模式但您可以访问源代码,则另一种方法是使用系统 ViewServer as the backend if your device has secure mode disabled or LocalViewServer正在测试的应用程序。

编辑

ViewCliet 应对上述后端的差异。也就是说,使用不同的后端,相同的脚本可以 运行 保持不变。

例如强制dump使用ViseServer只是运行

$ dump --force-view-server-use --all

您可以在脚本中执行相同的操作。