0% found this document useful (0 votes)
14 views2 pages

Selenium Pagination Techniques in Java

Uploaded by

Paresh Sonparote
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Selenium Pagination Techniques in Java

Uploaded by

Paresh Sonparote
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Pagination in selenium using core java

Pagination Solution One:

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 =[Link]([Link]("//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++){


[Link](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 =[Link]([Link]("//div[@class='nav-


pages']//a"));

webElement NextButton= [Link]([Link]("//*[@id='nextbutton id']"))

int LastPageNumber =
(int)[Link]([Link]("//*[@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++)


{

[Link]();
}
} 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 [Link] 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 =[Link]([Link]("//div[@class='nav-


pages']//a"));

webElement NextButton= [Link]([Link]("//*[@id='nextbutton id']"));

webElement prevButton= [Link]([Link]("//*[@id='prevButtonid']"));

int LastPageNumber =
(int)[Link]([Link]("//*[@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.

if([Link]())
{

[Link]();
}
else {
sop("pagination not exists");
}
}}
Email This

You might also like