键盘事件
废话不多说直接上包
from selenium.webdriver.common.keys import Keys
1、删除键 BACKSPACE
driver.find_element_by_xpath( element ).send_Keys(Keys.BACK_SPACE)
2、回车键 ENTER
driver.find_element_by_xpath( element ).send_keys(Keys.ENTER)
3、全选操作 CTRL + a
driver.find_element_by_xpath( element ).send_Keys(Keys.CANCEL,"a")
4、复制操作CTRL + c
driver.find_element_by_xpath( element ).send_Keys(Keys.CANCEL,"c")
5、粘贴操作 CTRL + v
driver.find_element_by_xpath( element ).send_Keys(Keys.CANCEL,"v")
6、剪切操作 CTRL + x
driver.find_element_by_xpath( element ).send_Keys(Keys.CANCEL,"x")
7、撤销操作 CTRL + z
driver.find_element_by_xpath( element ).send_Keys(Keys.CANCEL,"z")
8、Shift + Ctrl + Home 如果光标在最后时,就相当于执行 CTRL + a
content_ele.send_keys(Keys.SHIFT, Keys.CONTROL, Keys.HOME)
总结
本篇文章就到这里了,希望能够给你带来帮助,也希望您能够多多关注编程网的更多内容!