标签:mon sel 点击 drive time strong import ext form
鼠标操作由ActionChains类来完成鼠标操作
perform() 执行鼠标操作
move_to_element() 鼠标悬浮;最常用的操作
double_click() 双击操作
context_click() 右键操作
drag_and_drop() 拖拽操作:鼠标左键按住并拖拽元素到另一个区域,然后释放鼠标
from selenium.webdriver.common.action_chains import ActionChains as AC
AC(driver).方法名(元素).perform()
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains as AC from selenium.webdriver.common.by import By import time driver = webdriver.Chrome() driver.get(‘https://www.baidu.com/‘) time.sleep(3) # 百度首页,设置链接元素定位 ele = driver.find_element(By.XPATH,"//div[@id=‘u1‘]/a[text()=‘设置‘]") # 对设置链接进行鼠标悬浮操作 AC(driver).move_to_element(ele).perform() # # 对设置链接进行鼠标悬浮并点击操作 # AC(driver).move_to_element(ele).click(ele).perform()
标签:mon sel 点击 drive time strong import ext form
原文地址:https://www.cnblogs.com/Aphrodite/p/10518178.html