WebElement searchInput = driver.findElement(By.name("q"));
searchInput.sendKeys("Playwright");// Wait for suggestion list items to appear:
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
List<WebElement> suggestions = wait.until(
ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("ul.suggestions li"))
);
// Click matching option:
for (WebElement item : suggestions) {
if (item.getText().contains("Playwright Java")) {
item.click();
break;
}
}