【问题标题】:After Accepting a popup, Appium can’t find any element in the app接受弹出窗口后,Appium 在应用程序中找不到任何元素
【发布时间】:2018-12-19 08:20:11
【问题描述】:

ENV:- Appium 最新 1.6.4,Android 7.1.1

我在使用 appium 时遇到了问题,我测试了在 android 本机应用程序登录屏幕上登录,关闭最新弹出窗口并在下一个活动时按下菜单按钮。在此活动中,appium 无法获取任何元素。也无法获取页面源。它尝试执行任何操作并无限期挂起,直到应用程序或测试关闭。在此之前,所有操作都执行良好。我想不通。我的应用程序有问题吗?感觉appium在activity上看不到任何东西。

Appium 日志:

[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“6”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“6”}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:true}
[AndroidBootstrap] Received command result from bootstrap
[W3C] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/d74e0285-8c9f-48b1-9b86-963572ea80a9/element/6/click 200 3166 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/d74e0285-8c9f-48b1-9b86-963572ea80a9/element
[HTTP] {“using”:“xpath”,“value”:"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]"}
[W3C] Calling AppiumDriver.findElement() with args: [“xpath”,"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“d74e0285-8c9f-48b1-9b86-963572ea80a9”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 30000 ms for condition
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]",“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘//android.widget.EditText[contains(@resource-id,‘com.myapp:id/messageEdit’)]’ using ‘XPATH’ with the contextId: ‘’ multiple: false

【问题讨论】:

    标签: android appium-android


    【解决方案1】:

    我添加了以下功能,我的问题得到了解决。

    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiAutomator2");

    【讨论】:

      【解决方案2】:

      即使我们在使用 Android 应用时也遇到了同样的问题。尝试了很多东西,但将应用程序发送到后台并重新启动解决了我的问题。

      1. 关闭弹出窗口
      2. 将应用发送到后台

        def backgroundApp(duration)
         background_app duration
        end
        
      3. 应用程序将在提到的持续时间后重新启动

      4. 现在尝试检查元素

      我希望这也能解决你的问题:)

      【讨论】:

        猜你喜欢
        • 2018-07-11
        • 2019-08-12
        • 2013-01-16
        • 2018-06-04
        • 1970-01-01
        • 2019-07-10
        • 2019-07-17
        • 2017-01-30
        • 1970-01-01
        相关资源
        最近更新 更多