selenium 键盘事件

# 要想使用键盘事件,得导入键盘事件类
from selenium.webdriver.common.keys import Keys
from selenium import webdriver

import time

driver = webdriver.Chrome()
driver.get("https://www.baidu.com")

ele = driver.find_element_by_id("kw")

ele.send_keys("selenium")

time.sleep(3)

# 退格键
ele.send_keys(Keys.BACK_SPACE)
time.sleep(3)
# 全选操作
ele.send_keys(Keys.CONTROL,'A')
# 剪切操作
ele.send_keys(Keys.CONTROL,'x')
time.sleep(3)

 

posted @ 2021-07-01 21:31  大熊童鞋  阅读(66)  评论(0编辑  收藏  举报