【发布时间】:2021-12-16 14:39:22
【问题描述】:
我有一个看起来像这样的 html:
<div class='textContainer'>
<div class='textLabel'> </div>
<div class='text'>
"First Line of text"
"Second Line of text"
"Third line of text"
</div>
</div>
我可以轻松地创建一个定位器来查找包含文本的节点,但是我需要专门针对文本的第一行和第三行运行一个断言......所以,我需要特定的定位器。 喜欢
//div[@class='text']/text[1]//div[@class='text']/text[3]
这有可能吗?
任何帮助将不胜感激。
谢谢!
【问题讨论】:
-
可能,是的。但是提取文本行很繁琐。我相信您可以在换行符周围使用 substring-before() 和 substring-after() 来提取每一行。