如何通过 Xpath 按下一个元素

How to press an Element by Xpath

我想按以下层次结构单击一个元素(在 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; }

评论中提到也是为了解决这样的问题,X-Path不得包括单反逗号,除非与 contains 或任何其他字符串操作一起使用 -

按如下方式更改 x 路径应该有效 -

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