【发布时间】:2016-07-01 18:06:41
【问题描述】:
我对 Selenium 非常陌生,刚刚学到了一些东西并尝试自动化。无法在 Selenium webdriver 中为以下元素找到一个元素:
<div class="navBg withSubMenu">
<table id="topnav" class="navTable" cellspacing="0" cellpadding="0" style="-moz-user-select: none; cursor: default;">
<tbody>
<tr>
<td class="logoCell navCell" valign="top">
<td class="navItem navCell relative selected">
<td class="navItem navCell relative notSelected">
<a class="content tasks" href="/tasks/otasklist.do">
<div class="label" style="z-index:155; ">TASKS</div>
<div class="img"> </div>
</a>
</td>
<td class="navItem navCell relative notSelected">
<a class="content reports" href="/reports/reports.do">
</td>
<td class="navItem navCell relative notSelected">
<td class="menuCell navCell" valign="top">
</tr>
<tr class="secondLevelRow">
</tbody>
</table>
我写过类似的代码
driver1.findElement(By.xpath("//*[Contains(@class,'content tasks')]")).click();
请任何人帮助我。
还请推荐一些站点或链接以了解有关定位器的更多信息,尤其是 xpath。我尝试了一些,但没有深入了解。
提前致谢。
【问题讨论】: