Wait- Expected conditions not working for auto-suggestion within Yahoo Finance page using Selenium and Java

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?

WebDriver driver = new ChromeDriver();

WebDriverWait wait = new WebDriverWait(driver,5);
List<WebElement>dd_list= wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//ul[@class='modules_list__1zFHY']/li")));

for(WebElement ele : dd_list) {

    if (ele.getText().contains("NCLH.VI")) {
        System.out.println("i got the element");

Read more here: https://stackoverflow.com/questions/64898016/wait-expected-conditions-not-working-for-auto-suggestion-within-yahoo-finance-p

Content Attribution

This content was originally published by my3rddimension at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: