首页 > 其他分享 >常见键盘操作

常见键盘操作

时间:2022-10-26 17:12:26浏览次数:55  
标签:keys 常见 driver selector 键盘 sleep 操作 find css

from  selenium import webdriver
from time import sleep
#导入对键盘操作的类
from selenium.webdriver.common.keys import Keys

driver=webdriver.Firefox()
driver.get("https://www.baidu.com")
driver.find_element_by_css_selector("#kw").send_keys("python")
sleep(2)

#全选
driver.find_element_by_css_selector("#kw").send_keys(Keys.CONTROL,"a")
sleep(2)
#复制或剪切
driver.find_element_by_css_selector("#kw").send_keys(Keys.CONTROL,"c")
#driver.find_element_by_css_selector("#kw").send_keys(Keys.CONTROL,"x")
sleep(2)

driver.get("https://www.sogou.com/")
sleep(2)

#粘贴关键词
driver.find_element_by_css_selector(".sec-input").send_keys(Keys.CONTROL,"v")
sleep(2)
driver.find_element_by_css_selector("#stb").click()
sleep(4)

driver.quit()

标签:keys,常见,driver,selector,键盘,sleep,操作,find,css
From: https://www.cnblogs.com/hahaniuer/p/16829108.html

相关文章