1

I'm just trying one string in search box like "testing" and then wait for the list of search option is visible and then printing the count of visible list.but getting 0 count. Below is the code that I'm using.

    driver.get("https://www.google.com/");
    driver.findElement(By.xpath("//input[@class=\"gLFyf gsfi\"]")).sendKeys("testing");

    WebElement wait = (new WebDriverWait(driver, 10))
              .until(ExpectedConditions.presenceOfElementLocated(By.className("UUbT9")));


    List<WebElement> search_List=driver.findElements(By.xpath("//*[@role=\'listbox\']/li/div//span"));
    System.out.println(search_List.size());

    for(WebElement we:search_List) {
        System.out.println(we.getText());
        if(we.getText().contains("testing types")) {
            we.click();
            break;
        }   
    }
vvns
  • 3,548
  • 3
  • 41
  • 57

1 Answers1

0

Can you try with this cssSelector

   ul[class='erkvQe'] > li

Edit: Your code is working fine on my end. I am getting 10. If you are still getting 0. Try with my cssSelector. Both work.

myoz89
  • 26
  • 2