【问题标题】:How to press an Element by Xpath如何通过 Xpath 按下元素
【发布时间】:2016-10-14 16:04:35
【问题描述】:

我想通过以下层次结构单击一个元素(在 Appium 中,使用 Selenium):

(1)LinerLayout --> android.widget.LinearLayout
   (0)RelativeLayout  --> android.widget.RelativeLayout
      (0)ImageView  -->  android.widget.ImageView

我曾尝试使用以下 Xpath,但没有任何成功。

[FindsBy(How = How.XPath, Using  = "//'android.widget.LinearLayout[1]/android.widget.RelativeLayout[0]/android.widget.ImageView[0]'")]
 public IList<IWebElement> SearchStreetButton { get; set; }

【问题讨论】:

  • 尝试删除单个引号为 -"//android.widget.LinearLayout[1]/android.widget.RelativeLayout[0]/android.widget.ImageView[0]"
  • 完美。不幸的是,我无法将其标记为已回答

标签: c# android selenium xpath appium


【解决方案1】:

正如 cmets 中所述,为了解决此类问题,X-Path 不应包含单个引号,除非与 contains 或任何其他字符串操作 -

如下更改 x-path 应该可以工作 -

"//android.widget.LinearLayout[1]/android.widget.RelativeLayout[0]/android.wid‌​get.ImageView[0]"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-03
    • 1970-01-01
    • 2019-08-08
    • 2020-08-14
    • 2021-05-07
    • 2021-12-13
    • 2016-11-26
    • 1970-01-01
    相关资源
    最近更新 更多