Below code is not able to identify the list of webelements if they are identified inside a wait condition. I get an exception as timeoutexception and unable to identify the element for the specified xpath.
However if I directly access the elements without wait condition , the values are assigned to the list Variable, why is this so?
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("https://www.finance.yahoo.com");
driver.manage().window().maximize();
driver.findElement(By.xpath("//input[@id='yfin-usr-qry']")).sendKeys("nclh");
WebDriverWait wait = new WebDriverWait(driver,5);
List<WebElement>dd_list= wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//ul[@class='modules_list__1zFHY']/li")));
System.out.println(dd_list.size());
for(WebElement ele : dd_list) {
if (ele.getText().contains("NCLH.VI")) {
System.out.println("i got the element");
}
}