【发布时间】:2019-12-30 00:56:22
【问题描述】:
我想通过 Selenium 查找表中行的索引(10 行):
<table _ngcontent-c4="" class="table table-striped table-br" xpath="1">
<tr _ngcontent-c4="" plan-id="41220451" xpath="1">
<tr _ngcontent-c4="" plan-id="41220452" xpath="1">
<tr _ngcontent-c4="" plan-id="41220453" xpath="1">
<tr _ngcontent-c4="" plan-id="41220454" xpath="1">
<tr _ngcontent-c4="" plan-id="41220455" xpath="1">
<tr _ngcontent-c4="" plan-id="41220456" xpath="1">
<tr _ngcontent-c4="" plan-id="41220457" xpath="1">
<tr _ngcontent-c4="" plan-id="41220458" xpath="1">
<tr _ngcontent-c4="" plan-id="41220459" xpath="1">
<tr _ngcontent-c4="" plan-id="41220460" xpath="1">
问题是找到plan_id ="41220457" (index = 7)所在的行
我尝试使用多个定位器,但没有成功。
【问题讨论】:
-
你能展示一下到目前为止你做了什么吗?
-
全局问题是点击表格中的按钮。我必须单击第 7 行上的按钮。我试过这个: driver.FindElement(By.XPath("//.../table[@class='table table-striped table-br']/tbody/tr[contains(@plan-id,'41220457') ]/td[8]/div[1]/button[1]").Click();