selenium 复制粘贴

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep

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

driver.find_element_by_css_selector("#kw").send_keys("Python")
sleep(4)

#键盘全选操作
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')
sleep(2)

#键盘剪切操作
# driver.find_element_by_css_selector("#kw").send_keys(Keys.CONTROL,'x')
# sleep(2)

driver.get("https://cn.bing.com/")
sleep(4)
driver.find_element_by_css_selector("#sb_form_q").send_keys(Keys.CONTROL,'v')
sleep(4)
driver.find_element_by_css_selector(".b_searchboxSubmit").click()
sleep(4)

selenium 复制粘贴

上一篇:Markdown零基础小知识


下一篇:Object.keys()、Object.values()、Object.entries()的用法