Selenium之键盘事件

Selenium之键盘事件

 

 

 

 

 

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.get(url='http://www.baidu.com/')
driver.maximize_window()
input_obj = driver.find_element(by=By.ID, value='kw')

input_obj.send_keys('By可以阿')
# 全选
input_obj.send_keys(Keys.CONTROL, 'a')
time.sleep(1)
# 复制
input_obj.send_keys(Keys.CONTROL,'c')
time.sleep(1)
# 清空
input_obj.clear()
time.sleep(1)
# 粘贴
input_obj.send_keys(Keys.CONTROL,'v')
time.sleep(1)
input_obj.send_keys(Keys.ENTER)
time.sleep(6)
driver.close()

 

posted @ 2021-06-19 17:20  断浪狂刀忆年少  阅读(72)  评论(0编辑  收藏  举报