• selenium--键盘事件


    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
  • 相关阅读:
    遇到屏蔽selenium的站点如何突破
    subprocess.Popen stdout重定向内容实时获取
    thinkphp Composer安装指南
    职场片
    php。。。
    多线程相关
    狂刷1000题~~2
    狂刷1000题~~1
    关于eclipse中看不到源码的问题
    一篇看懂++i i++
  • 原文地址:https://www.cnblogs.com/annawong/p/10208907.html
Copyright © 2020-2023  润新知