Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

I've got some tests where I'm checking that the proper error message appears when text in certain fields is invalid. One check for validity is that a certain textarea element is not empty.

If this textarea already has text in it, how can I tell selenium to clear the field?

something like:

driver.get_element_by_id('foo').clear_field();

1 Answer

0 votes
by (62.9k points)

Using clear( ) command to clear a text box field

@Test

public void clearTheTextBox(){webdriver.findElement(By.xpath(“XXXXXX”)).clear();

}

Hope this helps! 

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...