【发布时间】:2018-09-06 21:58:00
【问题描述】:
我正在尝试提取文本“2000”并将其存储在 HTML 下方的字符串中:
<table class="table" _ngcontent-c13="">
<tbody _ngcontent-c13="">
<tr _ngcontent-c13="">
<th _ngcontent-c13="" scope="row">Amount</th>
<td class="" _ngcontent-c13="">
<b _ngcontent-c13="">$2000</b>
</td> <!-- Added by edit -->
</tr> <!-- Added by edit -->
</tbody> <!-- Added by edit -->
</table> <!-- Added by edit -->
我在 XPath 下尝试,但它返回 null:
String text= driver.findelement(by.xpath("xpath="//table[@class='table']/tbody/tr[1]/td")).getAttribute("value")
【问题讨论】:
-
该代码不会返回 null,它甚至不会编译。请花一点时间用您正在使用的实际代码更新您的问题。
标签: java selenium-webdriver xpath