У меня есть список в моей заявке.Список разделен на разделы, такие как «в настоящее время просматривается как», «недавно просмотренный», «персонал» и т. Д. Все элементы списка имеют одни и те же классы, поэтому идентифицировать элемент списка в недавно просмотренном разделе, например, не так просто..
Я попробовал следующее:
RecentlyViewed(".list-group-item:nth-of-type(3)"
.concat("~ .list-group-item:nth-of-type(4)"))
, но, похоже, возвращает только 1 элемент списка, а не оба.
Есть ли какие-либо указатели при возврате 3-го и 4-го элементов в списке?.
Кстати, вышеуказанный локатор передается методу, подобному следующему:
private WebElement sectionSearch(String locator, String empName) {
return wait.andGetAllElements(locator).stream()
.filter(ele -> ele.getAttribute("data-empno").equals(empName))
.findFirst()
.orElseThrow(() -> new RuntimeException("Could not find employee: ".concat(empName)
.concat(" in element : ").concat(locator)));
}
Любые идеи, где я могу пойти не так в отношении элементов списка, передаваемых в функцию поиска?
HTML-код выглядит следующим образом:
<div id="context-selector-search-results" class="list-group list-group-menu"><h4 class="text-muted">You are signed in as...</h4><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-link" data-empno="3000" data-url="api/context/select/3000"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="file/photo/T000~|~3000~|~2915483350193499~|~GIF~|~1~|~ok.gif" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">3000</small>
<br>
<strong class="context-selector-search-results-item-display-name">MANAGER3000, Mary G</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><h4 class="text-muted">Currently viewing...</h4><li class="list-group-item list-group-item-split active active-warning">
<a href="" class="list-group-item-link" data-empno="5029" data-url="api/context/select/5029"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="assets/ui/img/avatar.png" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">5029</small>
<br>
<strong class="context-selector-search-results-item-display-name">EMPLOYEE, Earl</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><h4 class="text-muted">Recently viewed...</h4><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-link" data-empno="5029" data-url="api/context/select/5029"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="assets/ui/img/avatar.png" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">5029</small>
<br>
<strong class="context-selector-search-results-item-display-name">EMPLOYEE, Earl</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-link" data-empno="5027" data-url="api/context/select/5027"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="assets/ui/img/avatar.png" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">5027</small>
<br>
<strong class="context-selector-search-results-item-display-name">EMPLOYEE, Earlene</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><h4 class="text-muted">My staff</h4><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-more" data-display-name="JETSON, Jane" data-expand-id="E~4112016">
<span class="tag tag-pill tag-primary hidden-xs-down float-xs-right">20</span>
</a>
<a href="" class="list-group-item-link" data-empno="4112016" data-url="api/context/select/4112016"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="file/photo/T000~|~4112016~|~2915756609048099~|~PNG~|~1~|~janejetson.png" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">4112016</small>
<br>
<strong class="context-selector-search-results-item-display-name">JETSON, Jane</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-more" data-display-name="PERSON130218, Eric" data-expand-id="E~130218">
<span class="tag tag-pill tag-primary hidden-xs-down float-xs-right">20</span>
</a>
<a href="" class="list-group-item-link" data-empno="130218" data-url="api/context/select/130218"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="assets/ui/img/avatar.png" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">130218</small>
<br>
<strong class="context-selector-search-results-item-display-name">PERSON130218, Eric</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-more" data-display-name="ROBOTS, Eric" data-expand-id="E~3001">
<span class="tag tag-pill tag-primary hidden-xs-down float-xs-right">20</span>
</a>
<a href="" class="list-group-item-link" data-empno="3001" data-url="api/context/select/3001"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="assets/ui/img/avatar.png" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">3001</small>
<br>
<strong class="context-selector-search-results-item-display-name">ROBOTS, Eric</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-more" data-display-name="SNODGRASS, Harold" data-expand-id="E~3003">
<span class="tag tag-pill tag-primary hidden-xs-down float-xs-right">20</span>
</a>
<a href="" class="list-group-item-link" data-empno="3003" data-url="api/context/select/3003"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="assets/ui/img/avatar.png" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">3003</small>
<br>
<strong class="context-selector-search-results-item-display-name">SNODGRASS, Harold</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-more" data-display-name="SNODGRASS, Harold" data-expand-id="E~3004">
<span class="tag tag-pill tag-primary hidden-xs-down float-xs-right">20</span>
</a>
<a href="" class="list-group-item-link" data-empno="3004" data-url="api/context/select/3004"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="assets/ui/img/avatar.png" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">3004</small>
<br>
<strong class="context-selector-search-results-item-display-name">SNODGRASS, Harold</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-more" data-display-name="VON DA EMPLOYEE, Eric" data-expand-id="E~5031">
<span class="tag tag-pill tag-primary hidden-xs-down float-xs-right">20</span>
</a>
<a href="" class="list-group-item-link" data-empno="5031" data-url="api/context/select/5031"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="file/photo/T000~|~2031~|~2915405557111499~|~JPEG~|~1~|~0A1BE6FA-43C4-4E85-A110-9F797A9525E6.jpeg" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">5031</small>
<br>
<strong class="context-selector-search-results-item-display-name">VON DA EMPLOYEE, Eric</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li><li class="list-group-item list-group-item-split">
<a href="" class="list-group-item-more" data-display-name="WAYNE, Bruce" data-expand-id="E~80000">
<span class="tag tag-pill tag-primary hidden-xs-down float-xs-right">20</span>
</a>
<a href="" class="list-group-item-link" data-empno="80000" data-url="api/context/select/80000"><div class="media">
<div class="media-left">
<img class="context-selector-search-results-item-image media-object rounded-circle img-avatar" alt="Avatar" src="file/photo/T000~|~80000~|~2915797423381199~|~JPG~|~1~|~bruce-wayne_197x282.jpg" data-holder-rendered="true">
</div>
<div class="media-body">
<small class="context-selector-search-results-item-empno">80000</small>
<br>
<strong class="context-selector-search-results-item-display-name">WAYNE, Bruce</strong>
<br>
<small class="context-selector-search-results-item-unit">Manufacturing Division</small><br>
</div>
</div></a>
</li></div>