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

 

上一篇:Jedis连接代码示例、管道和lua脚本街道


下一篇:Markdown基本用法笔记