【发布时间】:2016-09-14 17:24:51
【问题描述】:
我需要从包含单词“Produktgewicht”的网页中查找元素
这是我用来查找元素的代码:
String Weight=wd.findElement(By.xpath("//*[contains(text(), 'Produktgewicht')]")).getText();
这是网页的源代码:
<li>
<b>
Produktgewicht inkl. Verpackung:
</b>
6 Kg
</li>
我的代码的输出是 "Produktgewicht inkl. Verpackung:"
但我想要整个<li>
这是我想要的输出 "Produktgewicht inkl. Verpackung: 6 Kg"
我试过了
String Weight=wd.findElement(By.xpath("//*[contains(text(), 'Produktgewicht')]/following::li")).getText();
但它给了我下一个<li>
请帮帮我...... 在此先感谢:)
【问题讨论】:
-
<ul class =等于什么?
标签: jquery html css selenium xpath