我需要点击表格中的一行,我无法这样做。更具体地说,我需要点击ALL_USA,你可以在下面的代码中看到。 我的HTML代码如下:
<div id="table" arid="1" arwindowid="0" style="height: 299px; width: 638px;">
<div class="TableHdr" style="visibility: hidden; display: none; width: 638px;">
<div class="TableInner" style="top: 0px; height: 277px; width: 638px;">
<div class="BaseTableOuter" draghandler="BaseTable_DragHandler" style="height: 275px; width: 636px;">
<div class="BaseTableColHeaders" style="width: 636px; left: 0px;">
<div class="BaseTableInner" style="top: 16px; height: 259px; width: 636px; overflow-y: auto; overflow-x: hidden;">
<table id="T1" class="BaseTable" title="" style="width: 2px;">
<colgroup cols="1">
<tbody>
<tr class="hiddentablehdr">
<tr class="" tabindex="0" arrow="0">
<tr tabindex="0" arrow="1">
<tr tabindex="0" arrow="2">
<tr tabindex="0" arrow="3">
<tr class="SelPrimary" tabindex="0" arrow="4">
<td class="BaseTableCellOdd BaseTableCellOddColor BaseTableStaticText" "scope="row" style="width: 636px;">
<nobr class="dp " style="text-align: left; width: 636px;">
<span style="padding: 1px 4px;float:left;">ALL_USA</span>
</nobr>
</td>
</tr>
<tr tabindex="0" arrow="5">
答案 0 :(得分:1)
您可以使用xpath来定位范围文本:
driver.find_element_by_xpath("//span[text()='ALL_USA']").click();
答案 1 :(得分:0)
如果ALL_USA
可能会发生变化,那么您可以使用:
driver.find_element_by_css_selector("table.BaseTable tr.SelPrimary td span").click();