Automation Testing
Clear text from text area using selenium WebDriver.
We can clear text from the text area using Selenium webdriver. We shall use the clear method to remove the content from a text area or an edit box. First, we shall identify the text area with the help of any locator.
A text area is identified with a textarea tagname in the html code. Let us input some text inside the below text area, then clear the text.

Example
Code Implementation
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class TextAreaClear{
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\ghs6ko r\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
//URL launch
driver.get("http://www.uitestpractice.com/Students/Form");
// identify element
WebElement m = driver.findElement(By.id("comment"));
// enter text
m.sendKeys("Selenium");
// obtain value entered in text area
System.out.println("Value entered: " + m.getAttribute("value"));
// clear text area
m.clear();
// obtain value entered in text area after clear applied
System.out.println("Value after clear(): " + m.getAttribute("value"));
//browser close
driver.close();
}
}
