【问题标题】:did not match any elements不匹配任何元素
【发布时间】:2015-10-26 14:54:30
【问题描述】:

ValueError: Element locator 'id=com.test.robot:id/et1' 没有匹配任何元素。

即使应用源包含上述 id

令人困惑!

需要帮助!

【问题讨论】:

  • 我已经尝试了解决方案,但它不适合我。
  • 为什么我被否决了?提到的问题重复它的解决方案对我不起作用..所以我问了单独的问题。它错了吗?
  • 你被否决了,因为这个问题另一个问题的重复,并且质量非常低。你没有添加任何细节,也没有表现出任何研究的努力。我们绝对无法复制您的问题。我们应该如何回答这个问题?

标签: android appium robotframework


【解决方案1】:

我们可以使用多种技术定位元素。

其中一个 xpath 并且在任何情况下都可以肯定地工作

众所周知,我们的 UI 是基于 xml 的。 xpath 用于在 xml 文档中为我们要访问的元素指定特定节点

这是基于 xpath 的定位示例

Click Element   xpath=/hierarchy[@rotation="0"]/android.widget.FrameLayout[@index="0"]/android.view.View[@index="0"]/android.widget.FrameLayout[2]/android.widget.LinearLayout[@index="0"]/android.widget.ListView[@index="0"]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[@index="1"]/android.widget.TextView[@index="0"]

【讨论】:

  • 如何找到特定元素的 xpath
  • 您在目录中看到任何名为 log.html 的文件吗?
  • 是的,我看到了一个 log.html 文件
  • 您可能会在 log.html 中发生错误的地方看到应用 UI 的 xml
  • 如果您无法找到然后在 Appium Terminal 中查找应用 UI 的 xml,它将在解析应用屏幕时回显 xml
猜你喜欢
  • 2020-03-06
  • 1970-01-01
  • 2016-06-09
  • 1970-01-01
  • 2020-05-15
  • 1970-01-01
  • 2016-06-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多