The structure of the DOM is as shown below:
<ul>
<li>
<a href="#" role="button" class="js-pagination link" data-page="1">1</a>
</li>
<li>
<a href="#" role="button" class="js-pagination link active" data-page="2">2</a>
</li>
<li>
<a href="#" role="button" class="js-pagination link " data-page="3">3</a>
</li>
<li>
<a href="#" role="button" class="js-pagination link " data-page="4">4</a>
</li>
</ul>
I am tasked with selecting the next immediate element (not adjacent) after the element that contains
class="js-pagination link active"
. In this case, it is the third li
element.
I have attempted to use the following CSS selector:
"ul li a[class='js-pagination link active'] + li"
However, this is not working as it is searching for the li
on the same level as the a
tag. How can I achieve this using a CSS selector?
I am unable to use .has() as I am utilizing this selector in Selenium CSS select to locate elements.