Styrow.dev
Question 40 of 64

How do we clear the Textbox value in Selenium?

Question

How do we clear the Textbox value in Selenium?

Answer

We can clear the Textbox value by using clear() method. Below is the code

WebDriver driver = new FirefoxDriver();

driver.get(""https://www.gmail.com"");

driver.findElement(By.xpath(""xpathToBeGiven"")).sendKeys(""CodeGreen"");

driver.findElement(By.xpath(""xpathToBeGiven"")).clear();