Pagination automation | Selenium C# Forum

Pagination automation

F
Franz Kriesten Post on 16/07/2019

Hello,

I am trying to write a peice of code where in i am trying to search for an element under pagination, but its not working as expected. Please find the selenium and Html code below

 

Selenium code:

public void automatePagination()
{
IList<IWebElement> pagination = driver.FindElements(By.XPath("//div[@class='eq-pagination-container custom-pagination']/li/ul"));
int size = pagination.Count;
test.Log(Status.Info, "pagination size is" + pagination.Count);
if (size>0)
{
test.Log(Status.Info, "pagination exists");
for(int i=1; i<=size; i++)
{
try
{
driver.FindElement(By.XPath("//li[@id='list-arrow-rigt']")).Click();//click on next button
Thread.Sleep(5000);
test.Log(Status.Info, "Loop" + i);
}
catch(Exception e)
{
test.Log(Status.Info, "Error message is" + e.Message);
}
}
}

 

Html code:

<div class="eq-pagination-container custom-pagination"><li class="pagination-container">

<ul class="pagination" role="navigation" aria-label="Pagination"><li id="list-arrow-left" class="arrow arrow-left"><a href=""><i class="fal fa-caret-left"></i></a></li><div class="eq-user row expanded border-bottom " data-id="1254" data-name="Rita">
<div class="small-5 columns">
<p class="text-left" title="Rita">
Rita
</p>
</div>
<div class="small-5 columns">
<p class="text-left" title="Rita&nbsp;">
Rita&nbsp;
</p>
</div>
<div class="small-2 columns">
<span class="float-right dots-butns-wrapper show-for-large">
<a class="eq-delete-btn button clear hollow" title="Delete user">
<i class="fal i-btn fa-trash-alt"></i>
</a>
</span>
</div>
</div><li class="current"><a href="">1</a></li><li id="list-arrow-rigt" class="arrow arrow-right"><a href=""><i class="fal fa-caret-right"></i></a></li></ul></li></div>

 

F
Franz Kriesten Reply on 16/07/2019

Please find the below attachment for more clarification