基于元素文本的Selenium Xpath选择器 [英] Selenium xpath selector based on the element text
本文介绍了基于元素文本的Selenium Xpath选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下XHTML的Selenium xpath选择器将是什么:
What would a Selenium xpath selector be for the following HTML:
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
我需要让Selenium IDE根据元素文本在列表中找到第二个项目.我以为//li='Second'
可以解决问题,但显然没有.
I need to make Selenium IDE locate the second item on the list based on the element text. I thought //li='Second'
would do the trick, but apparently it does not.
推荐答案
我认为这就是您要寻找的
I think this is what you are looking for
ul/li[contains(text(), "Second")]
还有更好的
ul/li[text() = 'Second']
这篇关于基于元素文本的Selenium Xpath选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文