Clear text from textarea with selenium

后端 未结 9 1306
时光说笑
时光说笑 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条回答
  •  Happy的楠姐
    2020-12-02 09:38

    In my experience, this turned out to be the most efficient

    driver.find_element_by_css_selector('foo').send_keys(u'\ue009' + u'\ue003')
    

    We are sending Ctrl + Backspace to delete all characters from the input, you can also replace backspace with delete.

    EDIT: removed Keys dependency

提交回复
热议问题