1、鼠標雙擊
例如有些地方需要使用到雙擊修改信息等,就需要使用到鼠標雙擊模擬操作
from selenium import webdriver
from selenium.webdriver import ActionChains
action_chains = ActionChains(self.driver)
action_chains.double_click(self.driver.find_element(By.ID,"span_shorturl")).perform()
2、右鍵單擊
例如右鍵之后會出現菜單
from selenium import webdriver
from selenium.webdriver import ActionChains
action_chains = ActionChains(self.driver)
action_chains.context_click(self.driver.find_element(By.ID,"span_shorturl")).perform()
3、鼠標懸停
from selenium import webdriver
from selenium.webdriver import ActionChains
action_chains = ActionChains(self.driver)
action_chains.move_to_element(self.driver.find_element(By.ID,"span_shorturl")).perform()
4、鼠標拖動:比如 拖動某個對象、拖動滾動條
#定位元素的源位置
source = driver.find_element_by_id("id")
#定位元素要移到到的目標位置
target = driver.find_element_by_id("id")
action_chains = ActionChains(self.driver)