Selenium Java - Handling Form Elements
Given the following code snippet, what will be the value of the input field after execution?
driver.findElement(By.id("searchBox")).sendKeys("App");
new WebDriverWait(driver, Duration.ofSeconds(5))
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("ul.suggestions li")));
List options = driver.findElements(By.cssSelector("ul.suggestions li"));
for (WebElement option : options) {
if (option.getText().equals("Apple")) {
option.click();
break;
}
}
String value = driver.findElement(By.id("searchBox")).getAttribute("value"); 