I am trying to move through website pages using the website's page navigator, but it always stops clicking at page 13.
This is my code:
for (int i = 1; i <= numOfPages; i ) {
customWebDriver.getWebDriver().findElement(By.className("css-3a6490")).click();
Thread.sleep(3000);
}
I have also tried using the element under css-3a6490, css-15a7b5o:
for (int i = 1; i <= numOfPages; i ) {
customWebDriver.getWebDriver().findElement(By.className("css-15a7b5o")).click();
Thread.sleep(3000);
}
but it also didn't work.
Does someone knows what is the problem? Thanks
CodePudding user response:
Try with:
customWebDriver.getWebDriver().findElement(By.xpath("//button[@class='css-19a323y']//following-sibling::button[1]")).click();
Explanation of Xpath: A button with class css-19a323y (Which is the current selected page) and then selecting the following button (Which is the next available page)
Also use more time for Thread.sleep(3000);
because sometimes when you make pagination it takes more time, so better add more time, or using WebdriverWait and Expected conditions, here an example:
WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);
wait.until(ExpectedConditions.elementToBeClickable(By.id<locator>));