driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
time.sleep(2)
element = driver.find_element_by_id("kw")
time.sleep(1)
element.send_keys('selenium')
time.sleep(1)
#选中全部文字
element.send_keys(Keys.CONTROL+'a')
#退格
element.send_keys(Keys.BACKSPACE)
time.sleep(2)
driver.quit()
1、单独使用element.send_keys(Keys.BACKSPACE),退回删除单个字符
2、结合选中全部,然后退回,删除所有字符