【问题标题】:Need xpath for the country code国家代码需要xpath
【发布时间】:2016-03-19 08:52:45
【问题描述】:

有人可以帮助找到正确的 xpath 吗?

我需要捕获国家代码,因为我需要识别元素。我尝试遵循 xpath,但没有运气。

索引 1 处的线性布局

//[@class='android.widget.LinearLayout' 和 @index=1]/.//[@resource-id='com.whatsapp:id/country_code' 和 @索引=1]

//[@class='android.widget.LinearLayout' 和 @index=1]/..//[@resource-id='com.whatsapp:id/country_code' 和@index=1]

//[@class='android.widget.LinearLayout' 和 @index=1]/../[@resource-id='com.whatsapp:id/country_code' 和 @索引=1]

【问题讨论】:

    标签: xml xpath selenium-webdriver


    【解决方案1】:

    您发布的 XPath 均无效。基本上,谓词([] 括号中的表达式)需要应用于上下文元素,例如 TextView

    //android.widget.TextView[@resource-id='com.whatsapp:id/country_code']
    

    上面的 XPath 将在页面中的任何位置找到 <android.widget.TextView> 元素,其中 resource-id 属性值等于 "com.whatsapp:id/country_code"。假设resource-id 属性是唯一的,那么XPath 应该足以找到目标TextView

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-16
      • 1970-01-01
      • 2017-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多