Gibts in Selenium eine Möglichkeit, den Text im Textfeld eines Webelements zu löschen?

1 Antwort

Ich selbst benutze Python, ein Anwendungsbeipspiel für java kann ich Dir also nicht geben. Hab clear() auch noch nie gebraucht, sendKeys() dagegen schon.

org.openqa.selenium
Interface WebElement
void clear()
If this element is a text entry element, this will clear the value. Has no effect on other elements. Text entry elements are INPUT and TEXTAREA elements. Note that the events fired by this event may not be as you'd expect. In particular, we don't fire any keyboard or mouse events. If you want to ensure keyboard events are fired, consider using something like
sendKeys(CharSequence...)
with the backspace key. To ensure you get a change event, consider following with a call to
sendKeys(CharSequence...)
with the tab key.