如何在表中选择Record的链接包含多个不同类的行,每列具有相同的类名

问题描述 投票:2回答:1

<table class="table hover" id="resultTable">            
<thead>
<tr>
<th rowspan="1" class="checkbox-col"><input type="checkbox" id="ohrmList_chkSelectAll" name="chkSelectAll" value=""></th>
<th rowspan="1" style="width:400" class="header"><a href="http://opensource.demo.orangehrmlive.com/index.php/core/viewDefinedPredefinedReports?sortField=name&amp;sortOrder=ASC" class="null">Report Name</a></th>
<th rowspan="1" style="width:95"><span class="headerCell"></span></th>
<th rowspan="1" style="width:95"><span class="headerCell"></span></th>
</tr>            
</thead>
<tbody>
<tr class="odd">
<td><input type="checkbox" id="ohrmList_chkSelectRecord_5" name="chkSelectRow[]" value="5"></td>                                <td class="left">PIM Sample Report</td>
<td class="left"><a href="/index.php/core/displayPredefinedReport?reportId=5">Run</a></td>
<td class="left"><a href="/index.php/core/definePredefinedReport?reportId=5">Edit</a></td>
</tr>
<tr class="even">
<td><input type="checkbox" id="ohrmList_chkSelectRecord_6" name="chkSelectRow[]" value="6"></td>                                <td class="left">Sample Report</td>
<td class="left"><a href="/index.php/core/displayPredefinedReport?reportId=6">Run</a></td>
<td class="left"><a href="/index.php/core/definePredefinedReport?reportId=6">Edit</a></td>
</tr>
</tbody>
 </table>

我是selenium的初学者,所以我需要一个帮助来点击一个记录的链接(Run)来自表中的多个记录包含多个不同类的行,每个列具有相同的类名。我附上了代码段。

我试过这个Xpath但是没有用:

//table[@class='table hover']/tbody/tr/td[text()='PIM Sample Report'] and ./td[text()='Run']

有人可以帮我搞清楚吗?

java selenium xpath
1个回答
0
投票

尝试在XPath下面使用:

//td[.="PIM Sample Report"]/following-sibling::td[.="Run"]/a

这应该获取"Run"前面的链接td与文本"PIM Sample Report"

© www.soinside.com 2019 - 2024. All rights reserved.