#encoding=utf-8
import unittest
import time
from selenium import webdriver
from selenium.webdriver import ActionChains
import win32clipboard as w
import win32con

# 设置剪切板内容
def setText(aString):
    w.OpenClipboard()
    w.EmptyClipboard()
    w.SetClipboardData(win32con.CF_UNICODETEXT, aString)
    w.CloseClipboard()


class VisitSogouByIE(unittest.TestCase):

    def setUp(self):
        #启动IE浏览器
        #self.driver = webdriver.Firefox(executable_path = "e:\\geckodriver")
        self.driver = webdriver.Ie(executable_path = "e:\\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).release(div).perform()
        time.sleep(2)
        ActionChains(self.driver).click_and_hold(div).perform()
        time.sleep(2)
        ActionChains(self.driver).release(div).perform()

    def tearDown(self):
        # 退出IE浏览器
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()

 

相关文章:

  • 2021-11-02
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
猜你喜欢
  • 2021-10-11
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案