图片:
我必须单击文本所在的删除选项卡“goregaon-vashi”。我也尝试过使用 sibling ,但失败了。
<table class="table table-hover txCustomTable" data-ng-show="!fetchingTxTableData" style="">
<tbody style="margin-top: 0px;">
<!-- ngRepeat: currentRow in tableRows --><tr data-ng-repeat="currentRow in tableRows" data-ng-class="currentRow.activeClass" class="ng-scope" style="">
<!-- ngRepeat: currentColumn in metadata.columns --><td data-ng-repeat="currentColumn in metadata.columns" data-ng-class="currentColumn.dataClass" class="ng-scope emp-col-name">
<p compile="currentRow[currentColumn.dbCol].displayHtml"><a class="customerDetailsLink ng-scope" data-ng-click="callerScope.onShowStopOnMap($parent.currentRow.stop_points)">goregaon-vashi</a></p>
</td><!-- end ngRepeat: currentColumn in metadata.columns --><td data-ng-repeat="currentColumn in metadata.columns" data-ng-class="currentColumn.dataClass" class="ng-scope emp-col-actions">
<p compile="currentRow[currentColumn.dbCol].displayHtml"><a href="/client1/shuttle/routes/create?code=10214" class="ng-scope">Edit</a><a style="margin-left:10px;" data-ng-click="callerScope.onDeleteButtonPress('10214')" class="ng-scope">Delete</a></p>
</td><!-- end ngRepeat: currentColumn in metadata.columns -->
</td><!-- end ngRepeat: currentColumn in metadata.columns -->
</tr><!-- end ngRepeat: currentRow in tableRows -->
</tbody><tbody>
</tbody></table>
我尝试了类似的路径
driver.findElement(By.xpath("//*[contains(text(),'goregaon-vashi')]/following-sibling:://*[contains(text(),'Delete')]")).click();
最佳答案
您是否通过检查网页尝试过上面提到的xpath? 您提到的这个 xpath 是否突出显示了删除的 Web 元素?
我已经通过复制您的 HTML 进行了相同的尝试,但它不是..
您可以使用此 xpath 来识别删除:
//a[contains(.,'goregaon-vashi')]/../../..//*[.='Delete']
此处,Delete 元素不是“goregaon-vashi”元素的同级元素。因此,我们必须导航其父元素,并且应该使用以下同级概念。
关于java - 如何单击删除文本可用的特定行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56217940/