click() 鼠标点击动作;
send_keys() 输入字符串到文本输入框动作;
clear() 清除文本框动作;
具体代码:
# coding=utf-8 from selenium import webdriver driver = webdriver.Chrome() driver.maximize_window() driver.implicitly_wait(6) driver.get("https://www.baidu.com") driver.find_element_by_id("kw").send_keys("Selenium!") try: driver.find_element_by_id("kw").clear() print('test pass : clean successful') except Exception as e: print("Exception found",format(e))
参考文章:https://blog.csdn.net/u011541946/article/details/68927331