selenium的鼠标mouse操作

  selenium的鼠标mouse操作:

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time


driver=webdriver.Chrome()  #配置参数
driver.get("https://www.baidu.com")
above=driver.find_element_by_link_text(u"设置")
ActionChains(driver).move_to_element(above).perform()  #鼠标停留
#ActionChains(driver).move_to_element(above).move_to_element(elem) 移动   elem需要自己放元素
ActionChains(driver).move_to_element(above).context_click()  #鼠标单击
ActionChains(driver).move_to_element(above).double_click()  #鼠标双击
ActionChains(driver).move_to_element(above).drag_and_drop()  #拖放 先挪到这个位置上抓住,再抓到一个元素,再把它放了



time.sleep(10)

猜你喜欢

转载自www.cnblogs.com/my-global/p/12467526.html