I have a dynamically generated page with a huge list which contains NESTED LINK ELEMENTS.
Sometime the list items contain ONE hyperlink and sometimes they contain TWO hyperlinks.
The depth/level of the nested links varies so it is different every time I refresh the page.
IMPORTANT: Within each list item at least one link has a link text. These are the links I want.
BUT: The parent element of the link text varies every time I refresh the page.
<div class="listitem"> <div> <a href="https://www.testpage/user1"> </div> <div> <a href="https://www.testpage/user2"> <span> <div>user2</div> </span> </a> </div> </div> <div class="listitem"> <div> <a href="https://www.testpage/user3"> <div>user3</div> </a> </div> </div> <div class="listitem"> <div> <div> <a href="https://www.testpage/user4"> <span> <span>user4</span> </span> </a> </div> </div> </div> <div class="listitem"> <div> <div> <div> <a href="https://www.testpage/user5" /> </div> </div> <div> <a href="https://www.testpage/user6"> <div> <div>user6</div> </div> </a> </div> </div> </div>
The result should be a list with user2, user3, user4 and user6
- I alredy tried div/a[last()] but this returns ALL 6 hyperlinks
- And I tried (div/a)[last()] but this returns hyperlink 6 only
So my question is:
- Which xpath is needed to get the LAST HYPERLINK-DESCENDANTS OF ALL FOUR ITEMS.
- Or in other words: How to get the **HYPERLINKS WHERE THE HREF-ATRIBUTE EQUALS THE TEXT WITHIN THE LAST DESCENDANT ELEMENTS **