gpt4 book ai didi

java - 添加多个元素到列表并单击 cssSelector WebDriver Java

转载 作者:行者123 更新时间:2023-11-30 03:28:39 25 4
gpt4 key购买 nike

我试图将所有这些按钮添加到列表中,然后单击它们,我不明白如何通过 cssSelector 添加子按钮。

<md-toolbar class="md-tall md-default-theme" hide-sm=""></md-toolbar>

<md-card class="card-only-large md-default-theme" layout="column">

<!--

uiView: header

-->
<div class="ng-scope" ui-view="header"></div>
<!--

uiView: content

-->
<div class="ng-scope" flex="" layout="column" ui-view="content">
<md-content class="ng-scope md-default-theme">
<!--

phone layout start

-->
<div class="text-center" hide-gt-sm=""></div>
<!--

phone layout end

-->
<!--

tablet layout start

-->
<div class="tutor-schedule-tablet" hide-sm="">
<h3></h3>
<div class="schedule-day-navigation md-toolbar-tools" layout="row"></div>
<table class="tutor-schedule tutor-schedule-week" cellspacing="1">
<thead></thead>
<tbody>
<!--

ngRepeat: timeinterval in weekintervals[0].timeIn…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals"></tr>
<!--

end ngRepeat: timeinterval in weekintervals[0].ti…

-->
<tr class="ng-scope" ng-init="sectionIndex = $index" ng-repeat="timeinterval in weekintervals[0].timeIntervals">
<td id="timeintrval_10pm" class="timeinterval-name text-center ng-binding" scroll-if="timeinterval.name == '12pm'"></td>
<!--

ngRepeat: weekinterval in weekintervals

-->
<td class="ng-scope" ng-repeat="weekinterval in weekintervals">
<!--

{{weekinterval.timeIntervals[$parent.$index].name}…

-->
<!--

ngIf: weekinterval.timeIntervals[sectionIndex].di…

-->
<!--

ngIf: !weekinterval.timeIntervals[sectionIndex].d…

-->
<!--

ngIf: !weekinterval.timeIntervals[sectionIndex].d…

-->
<button class="md-primary md-button ng-scope" ng-if="!weekinterval.timeIntervals[sectionIndex].disabled && !weekinterval.timeIntervals[sectionIndex].isPastDate" ng-click="itemClicked_Weekly(weekinterval.timeIntervals[sectionIndex])" ng-class="{ 'timeinterval-selected' : weekinterval.timeIntervals[secti…led' : weekinterval.timeIntervals[sectionIndex].isPastDate }" tabindex="0"></button>

按钮似乎在表格中。

这就是我到目前为止的代码。

 WebElement parent = driver.findElement(By.cssSelector("table.tutor-schedule:nth-child(3)"));  
List<WebElement> children = parent.findElements(By.cssSelector(".md-primary .md-button"));
for (int i = 0; i < children.size(); i++) { children.get(i).click(); }

谢谢,顺便说一句,我正在使用 Java。

最佳答案

使用这些选择器解决了这个问题

 WebElement parent = driver.findElement(By.cssSelector(".tutor-schedule-tablet"));  
List<WebElement> children = parent.findElements(By.cssSelector("button.md-primary.md-button.ng-scope"));
System.out.print("\n" + children);
for (int i = 0; i < children.size(); i++) { children.get(i).click(); }

关于java - 添加多个元素到列表并单击 cssSelector WebDriver Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29608324/

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