How to capture visible web elements of the list in loop?

Hi,

I am working on one of the scenario where i have to catch all the elements of the list visible on the page. Then i have to click on next and then again capture visible elements of the list till i get the available date.

Here is my function:

WebDriverWait wait = new WebDriverWait(driver, 1000); while(flag) {

List abc = wait.until(ExpectedConditions .visibilityOfAllElementsLocatedBy(By.xpath(“//div//div[@data-tip=‘No tee-times available’]”))); System.out.println(abc.size()); Thread.sleep(1000);

for(WebElement e: abc) { System.out.println(e.getText()+" “); while(e.getText().contains(“Tee Times Unavailable”)) { try{ WebElement next = driver.findElement(By.xpath(”//div[@class=‘arrow-wrapper next slick-arrow’]")); next.click(); } catch(StaleElementReferenceException c) { c.printStackTrace(); }

} flag=false;

} }

Can anybody help me with this?

![](![](https://)https://)