Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I want to delete a default value of a textbox to enter the new value, but I am not getting how to do that.

I was thinking to use CTRL+a and then Delete but I'm not sure how to do this.

I even used WebDriver's comm and driver.findElement("locator").clear();

1 Answer

0 votes
by (62.9k points)

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 are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium training

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...