.
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
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();
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)
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver","D:\\Sandeep\\Soft\\chromedriver.exe");
WebDriver driver= new 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");
driver.findElement(By.id("pass")).sendKeys("Ram@123");
0 Comments