c# - 如何通过 Xpath 按下一个元素

标签 c# android selenium xpath appium

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

关于c# - 如何通过 Xpath 按下一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37803268/

相关文章:

python - 带有 Selenium 的 Firefox 空白网络浏览器

java - 通过 Selenium 访问时,DOM 未填充到 PhantomJS 中

c# - 如何将数字转换为下一个更高的五倍数?

c# - 从 DOCX 中提取表格

android - 未能传递结果 ResultInfo android

java - 将 TextView 或 TextView 数组传递给 Android 中的函数

c# - Windows 服务 : Session Unlock Event with Fast User Switching and Terminal Services Stopped and Disabled

c# - 有谁知道哪里有可以生成示例信用卡号的 c# 代码或 dll

Android SDK Manager - 我应该选择安装哪个包?

python - Selenium搜索元素,删除该元素然后验证该元素是否被删除