how to delete default values in text field using selenium?
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
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");
If you're looking for a solution from Selenium RC, you can use simply
// assuming 'selenium' is a healthy Selenium instanceselenium.type("someLocator", "");