• 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()

  • 相关阅读:
    20210131
    20210130
    20210129
    20210128
    20210127
    例3-7
    例3-5
    例3-4
    例3-3
    例3-2
  • 原文地址:https://www.cnblogs.com/nicole-zhang/p/10384181.html
Copyright © 2020-2023  润新知