添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

例如有些地方需要使用到双击修改信息等,就需要使用到鼠标双击模拟操作

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)

action_chains .drag_and_drop(source,target).perform()