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()

  • 相关阅读:
    array常用方法总结
    .babelrc参数小解
    async/await方法解析
    html5-entities.js消失问题
    h => h(App)解析
    package.json字段简要解析
    body-parser小解
    mongodb中的__v字段
    module.exports与exports
    freemarker判断对象是否为空
  • 原文地址:https://www.cnblogs.com/wwyydd/p/14416839.html
Copyright © 2011-2022 走看看