gpt4 book ai didi

selenium - 如何使用 Selenium 从表内可用的复选框列表中单击复选框

转载 作者:行者123 更新时间:2023-12-03 16:15:50 25 4
gpt4 key购买 nike

我一直试图单击一个特定的复选框,但是所有复选框内部都具有相同的标记和参数。仅文本(即复选框的名称)是变化的,但不幸的是,该文本也无法使用。请帮助我。

HTML代码:

<tr class="ng-scope" ng-repeat="group in groupsList | orderBy:'groupName'">
<td class="col-xs-4 ng-binding">
<input class="ng-scope ng-pristine ng-valid" type="checkbox" checklist-value="group" ng-model="checked"/>
Checkbox1 name
<br/>
</td>
</tr>
<!-- end ngRepeat: group in groupsList | orderBy:'groupName' -->
<tr class="ng-scope" ng-repeat="group in groupsList | orderBy:'groupName'">
<td class="col-xs-4 ng-binding">
<input class="ng-scope ng-pristine ng-valid" type="checkbox" checklist-value="group" ng-model="checked"/>
Checkbox2 name
<br/>
</td>
</tr>
<!-- end ngRepeat: group in groupsList | orderBy:'groupName' -->
<tr class="ng-scope" ng-repeat="group in groupsList | orderBy:'groupName'">
<td class="col-xs-4 ng-binding">
<input class="ng-scope ng-pristine ng-valid" type="checkbox" checklist-value="group" ng-model="checked"/>
Checkbox3 name
<br/>
</td>
</tr>
<!-- end ngRepeat: group in groupsList | orderBy:'groupName' -->
<tr class="ng-scope" ng-repeat="group in groupsList | orderBy:'groupName'">
<td class="col-xs-4 ng-binding">
<input class="ng-scope ng-pristine ng-valid" type="checkbox" checklist-value="group" ng-model="checked"/>
Checkbox4 name


答案将非常有帮助和赞赏。

我尝试过的 xpaths

//table/tbody/tr/td/input/following-sibling::text() 


这突出显示了所有文本,即复选框的名称

//table/tbody/tr/td/input/following-sibling::br/preceding::text()='Checkbox name'

//table/tbody/tr/td/input/text()\[preceding::br and contains(../text(),'Checkbox name')\][1]

最佳答案

您应该尝试使用以下xPath选择基于checkboxvisible text:-

//td[contains(., 'Checkbox1 name')]/input

关于selenium - 如何使用 Selenium 从表内可用的复选框列表中单击复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37744808/

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