#鼠标左键按下、松开操作
from selenium.webdriver import ActionChains
ActionChains(self.driver).click_and_hold(div).perform()
ActionChains(self.driver).release(div).perform()
import unittest
import time
from selenium import webdriver
from selenium.webdriver import ActionChains
class VisitSogouByIE(unittest.TestCase):
def setUp(self):
# 启动IE浏览器
self.driver = webdriver.Ie(executable_path="g:\\IEDriverServer")
def test_simulationLeftClickMouseOfProcess(self):
url = "http://127.0.0.1/test_mouse.html"
# 访问自定义的html网页
self.driver.get(url)
div = self.driver.find_element_by_id("div1")
from selenium.webdriver import ActionChains
import time
# 在id属性值为“div1”的元素上执行按下鼠标左键,并保持
ActionChains(self.driver).click_and_hold(div).perform()
time.sleep(2)
# 在id属性值为“div1”的元素上释放一直释放的鼠标左键
ActionChains(self.driver).