from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() driver.get("http://www.baidu.com") driver.maximize_window() driver.find_element_by_id("kw").send_keys("seleniumm") driver.find_element_by_id("kw").send_keys(Keys.BACKSPACE) #删除多输入的m driver.find_element_by_id("kw").send_keys(Keys.SPACE) #输入空格键 driver.find_element_by_id("kw").send_keys(Keys.CONTROL,"a") #ctrl+a全选输入框内容 driver.find_element_by_id("kw").send_keys(Keys.CONTROL,"x") #ctrl+x剪切 driver.find_element_by_id("kw").send_keys(Keys.CONTROL,"c") #ctrl+c复制 driver.find_element_by_id("kw").send_keys(Keys.CONTROL,"v") #ctrl+v粘贴 driver.find_element_by_id("kw").send_keys(Keys.ENTER) #回车键 driver.find_element_by_id("kw").send_keys(Keys.TAB) #制表键tab driver.find_element_by_id("kw").send_keys(Keys.ESCAPE) #回退键enter driver.find_element_by_id("kw").send_keys(Keys.F1) #键盘F1 driver.find_element_by_id("kw").send_keys(Keys.F12) #键盘F12