selenium的鼠標操作
阿新 • • 發佈:2018-07-30
mov click form ive implicit com and per driver
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.get(‘http://www.baidu.com‘)
driver.implicitly_wait(10)
‘‘‘ 鼠標懸停
mouse = driver.find_element_by_link_text(‘設置‘)
ActionChains(driver).move_to_element(mouse).perform()
driver.find_element_by_link_text(‘高級搜索‘).click()
‘‘‘
‘‘‘ 鼠標拖拽
mouse1 = driver.find_element_by_link_text(‘xxxxx‘)
mouse2 = driver.find_element_by_link_text(‘xxxxxx‘)
ActionChains(driver).drag_and_drop(mouse1, mouse2).perform()
‘‘‘
‘‘‘鼠標右擊
mouse1 = driver.find_element_by_link_text(‘xxxxx‘)
ActionChains(driver).context_click(mouse1).perform()
‘‘‘
‘‘‘鼠標雙擊
mouse1 = driver.find_element_by_link_text(‘xxxx‘)
ActionChains(driver).double_click(mouse1).perform()
‘‘‘
selenium的鼠標操作