【问题标题】:How to locate the Android ViewGroup element?如何定位 Android ViewGroup 元素?
【发布时间】:2018-03-07 02:53:43
【问题描述】:

有一个日历布局层次结构。我想找到 ViewGroup 中的每个元素。我可以通过对整个 XPath 进行硬编码来实现它,显然它的效率很低。有没有更好的方法来做到这一点?

屏幕截图和层次结构受到打击:

【问题讨论】:

    标签: java android viewgroup android-viewgroup


    【解决方案1】:

    我自己想出了一个简单的方法:

    Grid.androidDriver().findElementByXPath("//*[@resource-id='com.{path}:id/header_layout']/following::android.widget.LinearLayout[1]/descendant::android.widget.FrameLayout[@enabled='true']/android.widget.TextView[contains(@text,'"+date+"')]").click();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      • 2017-08-24
      • 2019-08-22
      • 1970-01-01
      相关资源
      最近更新 更多