I have a test case that requires typing in a partial value into an ajax based textfield and verifying the list has the expected content. If it does, select the content. An
A little variation using Prashanth's answer:
/**
* Selects the element at position idx from the autocomplete combo, considering the partialKeyword
* @param driver
* @param element
* @param partialKeyword
* @param idx
* @throws InterruptedException
*/
public static void selectAutoCompleteValue(WebDriver driver, WebElement element, String partialKeyword, Integer idx) throws InterruptedException{
element.sendKeys(partialKeyword);
Thread.sleep(1000);
List listItems = driver.findElements(By.cssSelector(".ui-autocomplete-item.ui-autocomplete-list-item"));
listItems.get(idx).click();
}
Hope this helps!