【发布时间】:2016-06-24 08:37:13
【问题描述】:
我在 python 中使用 selenium 来检查是否包含字体标签之间的文本,如果包含,则返回标签 tbody。
html代码:
<table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#000000" height="80">
<tbody>
<tr bgcolor="#666699">
<td height="17" bgcolor="#CCCC99">
<font size="2"><b><font face="Arial, Helvetica, sans-serif">PARTY 1</font></b></font>
</td>
</tr>
<tr>
some html code...
</tr>
</tbody>
</table>
如您所见,这是一个示例,如果其中有 PARTY 1,我需要检查 html 页面,如果有,则返回 tbody 元素。 我应该说没有办法使用 id 获取元素,因为还有其他表以相同的方式编写。 我已经尝试过使用 //font[contains(.,'PARTY 1')] 但它没有用
使用 selenium 并检查 PARTY 1 是否在并取回 tbody 元素的最佳方法是什么?
【问题讨论】:
-
//font[contains(.,'PARTY 1')]至少应该正确定位font元素。你有什么错误吗?
标签: python html selenium selenium-webdriver selenium-ide