【发布时间】:2015-10-02 12:27:06
【问题描述】:
这是部分html代码:
<td class="audit-context-break-word text-left" nowrap="nowrap">
<b class="ng-binding">PONumber</b></td>
<td class="audit-context-break-word text-left ng-binding">20202022 02_001 </td>
我只需要在里面获取文本(预期值:20202022 02_001)我尝试了以下变体:
By.xpath("/descendant::*[.='PONumber']/../descendant::*[@class=\"audit-context-break-word text-left ng-binding\"]/text()")
By.xpath("/descendant::*[.='PONumber']/../following::text()[1]")
问题是在 FirePath 中找到了选定的文本,但在测试中没有找到。超时异常导致失败,因为找不到元素
失败的原因是什么?
【问题讨论】:
-
必须是 XPath 吗?
-
不一定是XPath,其他方式也可以
标签: selenium xpath testng service-locator