python自动化测试——键盘事件
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome() driver.get("https://www.***.cn") #回车 driver.find_element(By.CSS_SELECTOR,"***").send_keys(Keys.ENTER)
#空格 driver.find_element(By.CSS_SELECTOR,"***").send_keys(Keys.SPACE)
#Tab driver.find_element(By.CSS_SELECTOR,"***").send_keys(Keys.TAB)
#删除 driver.find_element(By.CSS_SELECTOR,"***").send_keys(Keys.BACK_SPACE)
#Esc driver.find_element(By.CSS_SELECTOR,"***").send_keys(Keys.ESCAPE)
#组合键Ctrl+C driver.find_element(By.CSS_SELECTOR,"***").send_keys(Keys.CONTROL,'c')
#F1 driver.find_element(By.CSS_SELECTOR,"***").send_keys(Keys.F1)
#Pagedown driver.find_element(By.CSS_SELECTOR,"***").send_keys(Keys.PAGE_DOWN) driver.quit()
本文来自博客园,作者:OTAKU_nicole,转载请注明原文链接:https://www.cnblogs.com/nicole-zhang/p/10384181.html