Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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! 

Browse Categories

...