【问题标题】:I have a button where the text is in span, how to find it?我有一个按钮,文本在 span 中,如何找到它?
【发布时间】:2015-04-19 10:12:41
【问题描述】:

实际上它不是一个按钮(它充当按钮)而是一个文本(即域名),当用户点击它时,它将转到下一部分。

这是html:

<div id="domainCon2TitleLabel" class="tLabel">
<span>qa.xyz.com</span>
</div>

我尝试将 xpath 作为

wd.findElement(By.xpath("//span[contains(text(),'qa.xyz.com')]")).click();

但显示错误为

无法定位元素:{"method":"xpath","selector":"//span[contains(text(),'qa.xyz.com')]"}

能否告诉我如何识别该跨度的 xpath。

【问题讨论】:

  • 也适合我。检查此跨度是否不在 iframe 内。
  • 它不在 iframe 中,有没有其他方法可以得到它。

标签: xpath


【解决方案1】:

试试 xpath 表达式:

//*[text()[contains(.,'qa.xyz.com')]]

【讨论】:

  • 如果有效,请记住以这种方式接受答案,以便与他人分享
猜你喜欢
  • 1970-01-01
  • 2016-07-24
  • 2014-07-25
  • 2022-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-13
  • 2014-10-01
相关资源
最近更新 更多