The following list represents page navigation buttons:
<div class="list">
<ul class="pageNav">
<li class="paginate_button ">
<a href="#" controls="Tables_Table_0" data-idx="0" tabindex="0">1</a></li>
<li class="paginate_button ">
<a href="#" controls="Tables_Table_0" data-idx="1" tabindex="0">2</a></li>
<li class="paginate_button ">
<a href="#" controls="Tables_Table_0" data-idx="2" tabindex="0">3</a></li>
</ul>
</div>
To go to the second page for instance, I am using this Selenium Java code:
//after setting up webdriver
List<WebElement> li = driver.findElements(By.className("pageNav"));
System.out.println(li.get(2).getText());
li.get(2).click();
It's printing the text correctly "2", but not clicking or navigating correctly as if I was manually doing it on the actual website. I also tried replacing the link with an actual link like:
<a href="https://www.w3schools.com/html/">Visit our page</a>
But still no luck. What am I doing wrong?
Thank you in advanced!