- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to reset or clear an edit box in Selenium?
We can reset or clear an edit box in Selenium with the help of clear() method.
Code Implementation with clear().
Example
import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class ResetText { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String url = "https://www.tutorialspoint.com/index.htm"; driver.get(url); driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS); //entering text in the edit box driver.findElement(By.cssSelector("#gsc-i- id1")).sendKeys("Selenium"); Thread.sleep(1000); // resetting text from the edit box with clear() driver.findElement(By.cssSelector("#gsc-i-id1")).clear(); driver.close(); } }
- Related Articles
- How to press ENTER inside an edit box in Selenium?
- How to enter values in an edit box in Selenium with python?
- How to input letters in capital letters in an edit box in Selenium with python?
- How to get the value of the edit box in Selenium?
- How to reset or clear a form using JavaScript?
- How do you enter text in the edit box in Selenium?
- How to enter a letter in uppercase in the edit box using Actions in Selenium?
- How to edit a JavaScript alert box title?
- How to clear the form after submitting in Javascript without using reset?
- How to clear the text entered in Selenium with python?
- How to create or reset counters with JavaScript?
- How to delete or clear caching in Laravel?
- How to reset or change the MySQL root password?
- How to clear an ImageView in Android?
- How to upload a file in Selenium with no text box?

Advertisements