zoukankan      html  css  js  c++  java
  • Selenium自动化之鼠标双击操作

    鼠标双击操作

    from selenium.webdriver import ActionChains
    action_chains = ActionChains(self.driver)
    action_chains.double_click(inputBox).perform()

    import unittest
    import time
    from selenium import webdriver

    class VisitSogouByIE(unittest.TestCase):
    def setUp(self):
    # 启动IE浏览器
    self.driver = webdriver.Ie(executable_path = "g:IEDriverServer")

    def test_doubleClick(self):
        url = "http://127.0.0.1/test_doubleclick.html"
        # 访问自定义的html网页
        self.driver.get(url)
        # 获取页面输入元素
        inputBox = self.driver.find_element_by_id("inputBox")
        # 导入支持双击操作的模块
        from selenium.webdriver import ActionChains
        # 开始模拟鼠标双击操作
        action_chains = ActionChains(self.driver)
        action_chains.double_click(inputBox).perform()  #执行perform才会真正双击
        time.sleep(3)
    
    def tearDown(self):
        # 退出IE浏览器
        self.driver.quit()
    

    if name == 'main':
    unittest.main()

  • 相关阅读:
    verilog RTL编程实践之四
    TB平台搭建之二
    hdu3466 Proud Merchants
    poj2411 Mondriaan's Dream (用1*2的矩形铺)
    zoj3471 Most Powerful
    poj2923 Relocation
    hdu3001 Travelling
    poj3311 Hie with the Pie
    poj1185 炮兵阵地
    poj3254 Corn Fields
  • 原文地址:https://www.cnblogs.com/wwyydd/p/14416839.html
Copyright © 2011-2022 走看看