Skip to main content
edited tags
Link
João Farias
  • 11k
  • 2
  • 20
  • 40
edited body
Source Link
Temp13
  • 27
  • 1
  • 1
  • 5

Do not swear strongly if such a question has already been, but I searched and came across this solution:

List<WebElement> list1 =  (List<WebElement>) d.findElements(by.classname("item-list-entry ng-scope")); 
list1.get(12).click();

I write to Java, and I try to parse the list, go through it and click on the 3rd element. Unfortunately, it does not help me.

The structure of my html

<div id="search-results" class="row search-result">
<div class="col-sm-12 col-wog">
<div class="item-list-entry ng-scope" ng-if="currentSearchOptions.display =='item-list'">
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 1 </div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 2 </div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 3</div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 4 </div>
</div>
</div>
</div>

I need the 3rd item. My decision before was simple (xpath)

//*[@id="search-results"]/div/div[1]/div[3]/div[2]/div[3]/p

Do not swear strongly if such a question has already been, but I searched and came across this solution:

List<WebElement> list1 =  (List<WebElement>) d.findElements(by.classname("item-list-entry ng-scope")); 
list1.get(1).click();

I write to Java, and I try to parse the list, go through it and click on the 3rd element. Unfortunately, it does not help me.

The structure of my html

<div id="search-results" class="row search-result">
<div class="col-sm-12 col-wog">
<div class="item-list-entry ng-scope" ng-if="currentSearchOptions.display =='item-list'">
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 1 </div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 2 </div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 3</div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 4 </div>
</div>
</div>
</div>

I need the 3rd item. My decision before was simple (xpath)

//*[@id="search-results"]/div/div[1]/div[3]/div[2]/div[3]/p

Do not swear strongly if such a question has already been, but I searched and came across this solution:

List<WebElement> list1 =  (List<WebElement>) d.findElements(by.classname("item-list-entry ng-scope")); 
list1.get(2).click();

I write to Java, and I try to parse the list, go through it and click on the 3rd element. Unfortunately, it does not help me.

The structure of my html

<div id="search-results" class="row search-result">
<div class="col-sm-12 col-wog">
<div class="item-list-entry ng-scope" ng-if="currentSearchOptions.display =='item-list'">
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 1 </div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 2 </div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 3</div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 4 </div>
</div>
</div>
</div>

I need the 3rd item. My decision before was simple (xpath)

//*[@id="search-results"]/div/div[1]/div[3]/div[2]/div[3]/p

Source Link
Temp13
  • 27
  • 1
  • 1
  • 5

How to choose the nth element

Do not swear strongly if such a question has already been, but I searched and came across this solution:

List<WebElement> list1 =  (List<WebElement>) d.findElements(by.classname("item-list-entry ng-scope")); 
list1.get(1).click();

I write to Java, and I try to parse the list, go through it and click on the 3rd element. Unfortunately, it does not help me.

The structure of my html

<div id="search-results" class="row search-result">
<div class="col-sm-12 col-wog">
<div class="item-list-entry ng-scope" ng-if="currentSearchOptions.display =='item-list'">
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 1 </div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 2 </div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 3</div>
<div class="row ng-scope" ng-repeat="entry in searchResults">ITEM 4 </div>
</div>
</div>
</div>

I need the 3rd item. My decision before was simple (xpath)

//*[@id="search-results"]/div/div[1]/div[3]/div[2]/div[3]/p