[英]How to select a link of a Record in the table contains multiple Rows of different class with same class name for each column
<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&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>
I'm a beginner to selenium, so I need a help to click a link (Run)of a Record from multiple Records in the table contains multiple Rows of different class with same class name for each column. 我是硒的初学者,因此我需要帮助才能单击表中多个记录中的记录链接(运行),该记录包含不同类的多个行,每列具有相同的类名。 I have attached the code snippet.
我已经附上了代码片段。
I tried this Xpath but is not working: 我尝试了此Xpath,但无法正常工作:
//table[@class='table hover']/tbody/tr/td[text()='PIM Sample Report'] and ./td[text()='Run']
can someone help me to figure out this? 有人可以帮我弄清楚这个吗?
Try to use below XPath : 尝试在XPath下面使用:
//td[.="PIM Sample Report"]/following-sibling::td[.="Run"]/a
This should fetch the link "Run"
preceded by td
with text "PIM Sample Report"
这应该获取链接
"Run"
其后为td
以及文本"PIM Sample Report"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.