<table id="comms-table" class="table table-condensed">
<tbody>
<tr><th class="bordered" style="text-align: center;" width="50">Status</th><th class="bordered" width="130">Component</th><th class="bordered">Last heart-beat</th></tr>
<tr class="data_row">
<td style="text-align: center;"><button class="btn btn-mini btn-success"> </button></td>
<td class="bordered">FIRST</td>
<td class="bordered">5 seconds ago</td>
</tr>
<tr class="data_row">
<td style="text-align: center;"><button class="btn btn-mini btn-success"> </button></td>
<td class="bordered">SECOND</td>
<td class="bordered">17 seconds ago</td>
</tr>
</tbody>
</table>
答案 0 :(得分:0)
试试这个:
WebElement we = driver.findElement(By.xpath("//*[contains(text(),'FIRST')]/preceding::button[1]"));
we.click();