I have an application with a few sections with pics and each section has a scroll link to scroll right
<div class="owl-next">
<i class="fa fa-angle-right">
the div class attribute changes to "owl-next-disabled" when u can't scroll anymore. I want to be able to scroll to the last picture in each section. i have been able to come up with code below with one 'for' loop to loop through the div webelements but within the loop i am able to click only once before element not found exception in thrown because owl-next disabled' is not found.
List<WebElement> divtag=driver.findElements(By.xpath("//div[@class='owl-next']"));
Thread.sleep(1000);
int i=1;
if(divtag!=null)
{
for(WebElement clickright:divtag)
{
WebElement rightscroll=driver.findElement(By.xpath("//div/i[@class='fa fa-angle-right']"));
rightscroll.click();
WebElement ele=driver.findElement(By.xpath("//div/i[@class='owl-next disabled']"))!=null)
}
}
}
how do i scroll through till the attribute of the div tag is 'owl-next disabled'?
while(true)
{
WebElement parent = clickright.findElement(By.xpath("./.."));
if(parent.getAttribute("class").equalsIgnoreCase("owl-next disabled"))
break;
System.out.println(clickright.getAttribute("class"));
clickright.click();
}
Retrieved the parent tag and compared with disabled text, now its working.