【问题标题】:how to use xpath via ui automator in appium如何在 appium 中通过 ui automator 使用 xpath
【发布时间】:2017-03-14 20:02:21
【问题描述】:

appium 版本 - 1.2.0

如何创建 xpath 以使用附件中的元素“数据使用” 图片

安卓版本 - 4.4.2

【问题讨论】:

    标签: appium


    【解决方案1】:

    你不应该使用 xpath。请改用by.Name 定位器策略。与使用其他定位器策略相比,Xpath 的处理时间要长得多。

    但如果你需要使用 xpath,答案如下:

    driver.findElement(By.xpath("//TextView[contains(@text,'Data usage')]"));

    Read the xpath documentation for a better explanation

    【讨论】:

    • 我收到错误,在控制台中观察到显示未找到 xml [参考 remoteobject.jpg]
    【解决方案2】:

    尝试使用此 xpath。

    android.widget.TextView[contains(@text,'Data usage')]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-31
      • 2017-09-14
      • 2021-04-21
      • 2019-05-06
      • 1970-01-01
      • 2017-02-01
      • 2015-12-21
      • 2014-08-01
      相关资源
      最近更新 更多