Pagination Solution One:
List<webElement> pagination =driver.findElemnts(By.xpath("//div[@class='nav-pages']//a"));
// checkif pagination link exists
if(pagination .size()>0){
sop("pagination exists");
// click on pagination link
for(int i=0; i<pagination .size(); i++){
pagination.get(i).click();
}
} else {
sop("pagination not exists");
}
Pagination Solution Two:
List<webElement> pagination =driver.findElemnts(By.xpath("//div[@class='nav-pages']//a"));
webElement NextButton= driver.findElemnt(By.xpath("//*[@id='nextbutton id']"))
int LastPageNumber = (int)driver.findElemnt(By.xpath("//*[@text='>>]/preceding::/span[1]"));
// checkif pagination link exists
if(pagination .size()>0)
{
sop("pagination exists");
// click on pagination link
for(int i=1; i <LastPageNumber; i++)
{
NextButton.click();
}
} else {
sop("pagination not exists");
}
if(NextButton.isEnabled())
- Find the pagination elements by using findElemnts() and store as list of elements.
- Get the pagination size.
- Check pagination exist or not.
- If exist make a loop and click until last pagination size.
Ex:
List<webElement> pagination =driver.findElemnts(By.xpath("//div[@class='nav-pages']//a"));
// checkif pagination link exists
if(pagination .size()>0){
sop("pagination exists");
// click on pagination link
for(int i=0; i<pagination .size(); i++){
pagination.get(i).click();
}
} else {
sop("pagination not exists");
}
Pagination Solution Two:
- Find the pagination elements by using findElemnts() and store as list of elements.
- Get the pagination size.
- Get Last Page Number.
- Find Next Button of pagination.
- Check pagination exist or not by taking pagination size.
- If exist make a loop and click until last pagination number.
Ex:
List<webElement> pagination =driver.findElemnts(By.xpath("//div[@class='nav-pages']//a"));
webElement NextButton= driver.findElemnt(By.xpath("//*[@id='nextbutton id']"))
int LastPageNumber = (int)driver.findElemnt(By.xpath("//*[@text='>>]/preceding::/span[1]"));
// checkif pagination link exists
if(pagination .size()>0)
{
sop("pagination exists");
// click on pagination link
for(int i=1; i <LastPageNumber; i++)
{
NextButton.click();
}
} else {
sop("pagination not exists");
}
Pagination Solution Three:
- Find the pagination elements by using findElemnts() and store as list of elements.
- Get the pagination size.
- Get Last Page Number.
- Find Next Button for pagination.
- Check pagination exist or not by taking pagination size.
- Then check Nextbutton is enable or not.If enable go inside loop and clcik next button until it's not disable.
- If exist make a loop and click until last pagination number.
Ex:
List<webElement> pagination =driver.findElemnts(By.xpath("//div[@class='nav-pages']//a"));
webElement NextButton= driver.findElemnt(By.xpath("//*[@id='nextbutton id']"));
webElement prevButton= driver.findElemnt(By.xpath("//*[@id='prevButtonid']"));
int LastPageNumber = (int)driver.findElemnt(By.xpath("//*[@text='>>]/preceding::/span[1]"));
// checkif pagination link exists
if(pagination .size()>0)
{
sop("pagination exists");
// click on pagination link
for(int i=1; i <pagination .size(); i++)
{
//Check if nextbutton is enable or not.
{
NextButton.click();
}
else {
sop("pagination not exists");
}
}}