【发布时间】:2013-07-20 10:52:27
【问题描述】:
有多种方法可以找到它,但我想以特定的方式进行。这是-
为了获得一个包含一些文本的元素,我的框架以这种方式创建了一个 xpath-
@xpath = "//h1[contains(text(), '[the-text-i-am-searching-for]')]"
然后执行-
find(:xpath, @xpath).visible?
现在以类似的格式,我想创建一个 xpath,它只在页面中的任何位置查找文本,然后可以在 find(:xpath,@xpath).visible 中使用?返回真或假。
提供更多上下文: 我的 HTML 段落看起来像这样-
<blink><p>some text here <b><u>some bold and underlined text here</u></b> again some text <a href="www.link">Learn more</a> [the-text-i-am-searching-for]</p></blink>
但如果我尝试使用我的 xpath 所在的 find(:xpath, @xpath) 找到它 @xpath = "//p[contains(text(), '[the-text-i-am-searching-for]')]" 它失败了。
【问题讨论】:
-
给出适当的html相关部分,您提供的部分不足以帮助您。