下面是我遇到問題的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(迭代並選擇我需要的索引) –