A simple text input you can interact with using Selenium.
Locate by id element_text and send keys.
// Java
WebElement el = driver.findElement(By.id("element_text"));
el.sendKeys("Hello Selenium");
// Python
el = driver.find_element(By.ID, "element_text")
el.send_keys("Hello Selenium")
To assert value:
assert el.getAttribute("value").equals("Hello Selenium");
# Python: assert el.get_attribute('value') == 'Hello Selenium'
// Java - Full Test
WebElement input = driver.findElement(By.id("element_text"));
WebElement showBtn = driver.findElement(By.id("element_text_btn"));
WebElement clearBtn = driver.findElement(By.id("element_text_clear"));
input.clear();
input.sendKeys("Hello Selenium");
assert input.getAttribute("value").equals("Hello Selenium");
showBtn.click();
WebElement result = driver.findElement(By.id("element_text_result"));
assert result.getText().contains("Hello Selenium");
clearBtn.click();
assert input.getAttribute("value").equals("");
# Python - Full Test
input_field = driver.find_element(By.ID, "element_text")
show_btn = driver.find_element(By.ID, "element_text_btn")
clear_btn = driver.find_element(By.ID, "element_text_clear")
input_field.clear()
input_field.send_keys("Hello Selenium")
assert input_field.get_attribute("value") == "Hello Selenium"
show_btn.click()
result = driver.find_element(By.ID, "element_text_result")
assert "Hello Selenium" in result.text
clear_btn.click()
assert input_field.get_attribute("value") == ""
// Java - Alternative Solution
WebElement el = driver.findElement(By.id("element_text"));
el.clear();
el.sendKeys("Hello Selenium");
assert el.getAttribute("value").equals("Hello Selenium");
// Python - Alternative Solution
el = driver.find_element(By.ID, "element_text")
el.clear()
el.send_keys("Hello Selenium")
assert el.get_attribute('value') == 'Hello Selenium'
element_text.