Subscribe Us

How To Clear Text Box In Selenium Webdriver

.
Question : How To Clear TextBox In Selenium Wbdriver Using Java ?

Answer
By using the clear () command we clear the text box in selenium webdriver .

Clear()  
Clear method is a predefined method of selenium webdriver class . In selenium clear() method is used to clear the textbox.

Syntax 
The Basic syntax of clear() method is given below 

clear();

Example
driver.findElement(By.id("email")).clear();

Selenium Code To Clear The Text Box Field Using Java


package automation;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ClearMethod
 {
public static void main(String[] args)
 {
 System.setProperty("webdriver.chrome.driver","D:\\Sandeep\\Soft\\chromedriver.exe");
WebDriver drivernew ChromeDriver();
driver.get("https://facebook.com");
driver.findElement(By.id("email")).sendKeys("Ram@gamil.com");
driver.findElement(By.id("email")).clear();
driver.findElement(By.id("email")).sendKeys("Ram123@gamil.com");
driver.findElement(By.id("pass")).sendKeys("Ram@123");
}
}

Important Tags : How to Clear the text box field in selenium using java , how to clear the text box in selenium webdriver , Clear() method in selenium , How to delete the default value of text box in selenium  
How To Clear The Text Box In Selenium Webdriver

Post a comment

0 Comments