Clear text from textarea with selenium

后端 未结 9 1300
时光说笑
时光说笑 2020-12-02 09:13

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 el

9条回答
  •  粉色の甜心
    2020-12-02 09:39

    I ran into a field where .clear() did not work. Using a combination of the first two answers worked for this field.

    from selenium.webdriver.common.keys import Keys
    
    #...your code (I was using python 3)
    
    driver.find_element_by_id('foo').send_keys(Keys.CONTROL + "a");
    driver.find_element_by_id('foo').send_keys(Keys.DELETE);
    

提交回复
热议问题