下面是我遇到问题的HTML部分。我怎样才能点击一个表中的按钮?
我在试图做的事:我目前使用硒铬驱动程序来完成在网站上创建票证的过程。在某个页面上,我必须选择一个标签才能检查一些复选框(见下文)。但是,它们都具有相同的ID。我如何使用C#中的selenium chrome驱动程序来选择(例如第二个TOP_TAB & TOP_BUTTON),然后单击该元素。
<input type="hidden" name="tabsize" value="5">
<td id="TOP_TAB" width="10" class="leftRightBorder" style="width: 5px;">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('0','0');" align="center" nowrap=""><img src="images/left-cor.gif" width="5" height="18" border="0"></td>
<td id="TOP_BUTTON" style="cursor: pointer; font-size: 10px; background-color: rgb(181, 200, 217); border-bottom: 2px solid rgb(181, 200, 217); font-weight: normal;"
onclick="fun_HideShowBlock('0','0');" align="center" class="drop" nowrap="" bgcolor="#B5C8D9" width="88">Addendum 02</td>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('0','0');" align="center" nowrap=""><img src="images/right-cor.gif" width="5" height="18" border="0"></td>
</tr>
</tbody>
</table>
</td>
<td id="TOP_TAB" width="10" class="leftRightBorder" style="width: 5px;">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('1','1');" align="center" nowrap=""><img src="images/left-cor-light.gif" width="5" height="18" border="0"></td>
<td id="TOP_BUTTON" style="cursor: pointer; font-size: 10px; background-color: rgb(217, 223, 239); border-bottom: 0px solid rgb(217, 223, 239); font-weight: bold;"
onclick="fun_HideShowBlock('1','1');" align="center" class="drop" nowrap="" bgcolor="#B5C8D9" width="88">Addendum 01</td>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('1','1');" align="center" nowrap=""><img src="images/right-cor-light.gif" width="5" height="18" border="0"></td>
</tr>
</tbody>
</table>
</td>
<td id="TOP_TAB" width="10" class="leftRightBorder" style="width: 5px;">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('2','2');" align="center" nowrap=""><img src="images/left-cor.gif" width="5" height="18" border="0"></td>
<td id="TOP_BUTTON" style="cursor: pointer; font-size: 10px; background-color: rgb(181, 200, 217); border-bottom: 2px solid rgb(181, 200, 217); font-weight: normal;"
onclick="fun_HideShowBlock('2','2');" align="center" class="drop" nowrap="" bgcolor="#B5C8D9" width="88">Default Job</td>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('2','2');" align="center" nowrap=""><img src="images/right-cor.gif" width="5" height="18" border="0"></td>
</tr>
</tbody>
</table>
</td>
<td id="TOP_TAB" width="10" class="leftRightBorder" style="width: 5px;">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('3','3');" align="center" nowrap=""><img src="images/left-cor.gif" width="5" height="18" border="0"></td>
<td id="TOP_BUTTON" style="cursor: pointer; font-size: 10px; background-color: rgb(181, 200, 217); border-bottom: 2px solid rgb(181, 200, 217); font-weight: normal;"
onclick="fun_HideShowBlock('3','3');" align="center" class="drop" nowrap="" bgcolor="#B5C8D9" width="88">Default Job</td>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('3','3');" align="center" nowrap=""><img src="images/right-cor.gif" width="5" height="18" border="0"></td>
</tr>
</tbody>
</table>
</td>
<td id="TOP_TAB" width="10" class="leftRightBorder" style="width: 5px;">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('4','4');" align="center" nowrap=""><img src="images/left-cor.gif" width="5" height="18" border="0"></td>
<td id="TOP_BUTTON" style="cursor: pointer; font-size: 10px; background-color: rgb(181, 200, 217); border-bottom: 2px solid rgb(181, 200, 217); font-weight: normal;"
onclick="fun_HideShowBlock('4','4');" align="center" class="drop" nowrap="" bgcolor="#B5C8D9" width="88">Default Job</td>
<td id="TOP_BUTTON" style="cursor:hand;" onclick="fun_HideShowBlock('4','4');" align="center" nowrap=""><img src="images/right-cor.gif" width="5" height="18" border="0"></td>
</tr>
</tbody>
</table>
</td>
我将执行XPath来选择所有TOP_TAB元素(循环直到其需要的),然后第二个XPath查找所有的TOP_BUTTON(迭代并选择我需要的索引) –