how to delete default values in text field using selenium?
For page object model -
@FindBy(xpath="//foo")
public WebElement textBox;
now in your function
public void clearExistingText(String newText){
textBox.clear();
textBox.sendKeys(newText);
}
for general selenium architecture -
driver.findElement(By.xpath("//yourxpath")).clear();
driver.findElement(By.xpath("//yourxpath")).sendKeys("newText");
And was the code helpful? Because the code you are writing should do the thing:
driver.findElement("locator").clear();
If it does not help, then try this:
WebElement toClear = driver.findElement("locator");
toClear.sendKeys(Keys.CONTROL + "a");
toClear.sendKeys(Keys.DELETE);
maybe you will have to do some convert of the Keys.CONTROL + "a"
to CharSequence, but the first approach should do the magic