首页 > 解决方案 > 如何让 Appium 的检查器在 Android Native App 上刷新其 UI?

问题描述

Appium 检查器卡在 UI 部分的加载动画中,不允许获取当前的 UI 和元素。怎么能绕过呢?

我在 Windows 上运行 Appium 1.13.0,使用真正的 Android 设备并尝试检查 React 本机应用程序。检查器启动应用程序并显示初始屏幕(环境选择器)并允许检查/选择元素,但在点击后 - 它会显示一个不会停止的加载动画。尝试刷新无济于事。 在设备本身 - 应用程序已到达所需的屏幕。

从 Appium 的日志中,点击后会发生以下情况:

[MJSONWP (6564ecbb)] Responding to client with driver.click() result: true

[HTTP] <-- POST /wd/hub/session/6564ecbb-53f5-4c97-8456-f70f6ea3d747/element/1/click 200 141 ms - 76

[HTTP] 

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}

[HTTP] --> GET /wd/hub/session/6564ecbb-53f5-4c97-8456-f70f6ea3d747/source

[HTTP] {}

[MJSONWP (6564ecbb)] Calling AppiumDriver.getPageSource() with args: ["6564ecbb-53f5-4c97-8456-f70f6ea3d747"]

[HTTP] --> GET /wd/hub/session/6564ecbb-53f5-4c97-8456-f70f6ea3d747/screenshot

[HTTP] {}

[MJSONWP (6564ecbb)] Calling AppiumDriver.getScreenshot() with args: ["6564ecbb-53f5-4c97-8456-f70f6ea3d747"]

[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"source","params":{}}

[HTTP] --> GET /wd/hub/session/6564ecbb-53f5-4c97-8456-f70f6ea3d747/window/current/size

[HTTP] {}

[MJSONWP (6564ecbb)] Calling AppiumDriver.getWindowSize() with args: ["current","6564ecbb-53f5-4c97-8456-f70f6ea3d747"]

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"source","params":{}}

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: source

标签: reactjsappiumappium-androidinspector

解决方案


driver.FindElementByAndroidUIAutomator("UiSelector().text(\"WHATEVER TEXT\")").Click();

感谢@Dmitri T 的回复,我已经使用 Appium Studio 来检查元素——由于闪屏(我猜),我之前无法检查这些元素。后来,我仍然无法通过 XPath 和其他方法找到元素 - 可能是因为闪屏。

最终成功的是使用 FindElementByAndroidUIAutomator。这里有一个用法列表,最后我可以找到并点击。

我知道该解决方案与我原来的问题标题有点不同 - 但是这两种方法(Appium studio + FindElementByAndroidUIAutomator)为我的问题提供了解决方案。


推荐阅读