#鼠标操作
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
driver=webdriver.Firefox()
driver.get("http://www.***.net")
driver.maximize_window()
driver.refresh()
driver.find_element_by_css_selector("#kw").send_keys("python")
sleep(5)
element=driver.find_element_by_css_selector("#kw")
#双击操作
ActionChains(driver).double_click(element).perform()
sleep(3)
#右击操作
ActionChains(driver).context_click(element).perform()
sleep(3)
#鼠标悬停
above=driver.find_element_by_css_selector(".pf")
ActionChains(driver).move_to_element(above).perform
sleep(3)
driver.quit()
#键盘操作
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
driver=webdriver.Firefox()
driver.get("http://www.baidu.com")
driver.find_element_by_css_selector("#kw").send_keys("selenium")
sleep(3)
#全选
driver.find_element_by_css_selector("#kw").send_keys(Keys.CONTROL,'a')
#复制或剪切
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("http://www.sogou.com")
sleep(2)
#根据class定位
driver.find_element_by_css_selector(".sec-input").send_keys(Keys.CONTROL,'v')
sleep(3)
driver.quit()