简体   繁体   English

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

[英]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&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> 

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.

相关问题 当结果记录有两列具有相同名称的不同表时,如何在 jooq 中按名称选择列? - How can I select a column by name in jooq, when result record has two columns of different tables with the same name? 如何使用 Selenium 和 ZD52138787837ZDZ 名称从具有相同 class 名称和不同值的 3 个互连下拉列表中选择 select 选项 - How to select options from 3 interlinked dropdowns with the same class name and different values using Selenium and Java Jsoup选择查询具有相同类名的多个元素 - Jsoup select query multiple elements with same class name Jooq:如何将具有相同列名的Record映射到Pojo类中? - Jooq: How map Record into Pojo class with the same column names? 如何为每个jar从相同的源但不同的主类创建多个jar? - How can I create multiple jars from the same source but different main class for each jar? 不同包中的相同类名 - Same class name in different packages 使用 ObjectMapper 反序列化具有相同属性但 class 名称不同的多个对象 - Deserialize multiple objects with same attributes but different class name using ObjectMapper 选择每列具有多个条件的行 - select rows with multiple conditions on each column 如何使用 Selenium Webdriver 在表中的不同位置选择多行 - How to select multiple rows at different place in a table using Selenium Webdriver Selenium:如何使用相同的类名选择第n个按钮 - Selenium: How to select nth button using the same class name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM