Fix Python – Clear text from textarea with selenium

Question

Asked By – Isaac

I’ve got some tests where I’m checking that the proper error message appears when text in certain fields are 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()

Now we will see solution for issue: Clear text from textarea with selenium


Answer

driver.find_element_by_id('foo').clear()

This question is answered By – Isaac

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0