gpt4 book ai didi

selenium - Xpath从表格单元格中选择按钮,具体取决于特定单元格中包含的文本

转载 作者:行者123 更新时间:2023-12-03 17:02:18 24 4
gpt4 key购买 nike

在我的Web应用程序上,我试图选择表格中单元格内的按钮。

并非每个单元格都包含一个“显示详细信息”按钮,并且仅根据该单元格中的文本显示该按钮

下面的屏幕截图

enter image description here

<td>
Allocated
<button ng-show="row.entitlementId" id="btnShowDetails" class="btn btn-primary btn-sm" style="width: 110px; float:right;" ng-click="showAllocationMonetaryDetails(row.entitlementId, CisBusinessID);" title="Show Details">
<span class="glyphicon glyphicon-search"></span>Show Details
</button>
<br>
<div style="font-size: small; color: darkgreen" ng-show="row.manualEstablishCommandType >= 0">
Adjustment
</div>
<div style="font-size: small; color: darkgreen" ng-show="row.manualReclaimCommandType >= 0">

</div>
</td>


我试图使用以下xpath来定位显示详细信息按钮,但是它不起作用。

("//td[contains(.,'Allocated') and (contains(@id,'btnShowDetails'))]")


有人知道我如何选择“显示详细信息”按钮吗?

谢谢

最佳答案

@id='btnShowDetails'不是td的属性,而是子button的属性

请尝试在XPath下面选择所需的元素:

//td[starts-with(normalize-space(),'Allocated') and button[@id='btnShowDetails']]


要么

//td[normalize-space(text())='Allocated' and button[@id='btnShowDetails']]

关于selenium - Xpath从表格单元格中选择按钮,具体取决于特定单元格中包含的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52150965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com