Autocomplete (datalist)

Type to choose from suggestions.

How to test
el = driver.findElement(By.id("element_autocomplete"));
el.sendKeys("Apple");
# Python: driver.find_element(By.ID, "element_autocomplete").send_keys('Apple')

// Java - Full Test
WebElement el = driver.findElement(By.id("element_autocomplete"));
WebElement showButton = driver.findElement(By.id("auto_show"));
WebElement clearButton = driver.findElement(By.id("auto_clear"));
el.clear();
el.sendKeys("Apple");
assert "Apple".equals(el.getAttribute("value"));
showButton.click();
WebElement result = driver.findElement(By.id("auto_result"));
assert result.getText().contains("Apple");
clearButton.click();
assert el.getAttribute("value").equals("");

# Python - Full Test
el = driver.find_element(By.ID, "element_autocomplete")
show_button = driver.find_element(By.ID, "auto_show")
clear_button = driver.find_element(By.ID, "auto_clear")
el.clear()
el.send_keys("Apple")
assert el.get_attribute("value") == "Apple"
show_button.click()
result = driver.find_element(By.ID, "auto_result")
assert "Apple" in result.text
clear_button.click()
assert el.get_attribute("value") == ""

// Java - Alternative Solution
WebElement input = driver.findElement(By.id("element_autocomplete"));
input.clear();
input.sendKeys("Apple");
assert input.getAttribute("value").equals("Apple");

# Python - Alternative Solution
input_field = driver.find_element(By.ID, "element_autocomplete")
input_field.clear()
input_field.send_keys("Apple")
assert input_field.get_attribute("value") == "Apple"


Tester Task
  1. Locate the autocomplete input using id element_autocomplete.
  2. Clear the input field.
  3. Enter Apple.
  4. Click the Show value button.
  5. Verify the result displays Apple.
  6. Click the Clear button and verify the input is empty.