接受弹出窗口后,Appium在应用程序中找不到任何元素

时间:2018-07-11 10:21:10

标签: android appium-android

ENV:-Appium最新1.6.4,Android 7.1.1

我的appium出现问题,我测试了在android native应用程序登录屏幕上的登录名,关闭了新弹出式窗口,然后在下一个活动中按菜单按钮。在此活动中,鸦片无法获得任何元素。此外,它也无法获取页面源。它会尝试执行任何操作并暂停无限时间,直到应用程序或测试关闭。在此刻之前,所有动作均正常。我不知道。我的应用程序有问题吗?像appium这样的感觉看不到任何活动内容。

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

2 个答案:

答案 0 :(得分:1)

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

capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,“ uiAutomator2”);

答案 1 :(得分:0)

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

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

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

  4. 现在尝试检查元素

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