There is a text box on a webpage. My aim is to fill it with some values, then clear it, and then fill it with some other value.
I can do the fill part with sendKeys() method. But how to clear the text from the textbox?
PS: I am using Selenium Python
There is a text box on a webpage. My aim is to fill it with some values, then clear it, and then fill it with some other value.
I can do the fill part with sendKeys() method. But how to clear the text from the textbox?
PS: I am using Selenium Python
Hi Rebecca,
There are many ways by which you can clear the text in a text box (partially or fully), such as:
driver.get_element_by_id('foo').clear()driver.find_element_by_id('foo').clear()webElement.clear()driver.find_element_by_id('foo').send_keys(Keys.CONTROL + "a");
driver.find_element_by_id('foo').send_keys(Keys.DELETE);
webElement.sendKeys(Keys.BACK_SPACE) # do repeatedly, e.g. in while loop
driver.find_element_by_css_selector('foo').send_keys(u'\ue009' + u'\ue003') Hope this helps