我想按以下层次结构单击一个元素(在 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.widget.ImageView[0]"
关于c# - 如何通过 Xpath 按下一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37803268/