鼠标操作:
移动:action.move_to_element(setting).perform()
拖拽:action.drag_and_drop(setting1,setting2).perform()
双击:action.double_click(setting).perform()
右击:action.context_click(setting).perform()
单击:action.click(setting).perform()
定位百度上面设置里面的高级搜索为例:
from selenium import webdriver
from selenium.webdriver import ActionChains
import time
driver = webdriver.Firefox()
url = "https://www.baidu.com/"
driver.get(url)
#初始化ActionChains
action = ActionChains(driver)
#定位一个元素
setting = driver.find_element(‘xpath‘,"//span[text()=‘设置‘]")
#鼠标操作
#移动
action.move_to_element(setting).perform()
time.sleep(6)
driver.find_element(‘xpath‘,"//a[text()=‘高级搜索‘]").click()
driver.quit()
原文:https://www.cnblogs.com/jiang12/p/14594724.html