I need to enter some text in a autocomplete textbox. Then I will select a option from that autocomplete option and need to click it.
I have tried with the following code:
public static void main(String[] args) throws InterruptedException {
    // TODO Auto-generated method stub
    String textToSelect = "headlines today";
    WebDriver driver = new FirefoxDriver();
    driver.get("https://www.google.co.in/");
    Thread.sleep(2000);
    WebElement autoOptions= driver.findElement(By.id("lst-ib"));
    autoOptions.sendKeys("he");
    List<WebElement> optionsToSelect = driver.findElements(By.tagName("li"));
    for(WebElement option : optionsToSelect){
        System.out.println(option);
        if(option.getText().equals(textToSelect)) {
            System.out.println("Trying to select: "+textToSelect);
            option.click();
            break;
        }
    }