zoukankan      html  css  js  c++  java
  • Selenium学习:鼠标事件

    导入鼠标事件动作链

    from selenium.webdriver.common.action_chains import ActionChains

    定位到要操作的元素

    right_click = driver.find_element_by_id("XX")

    1. 鼠标右击

    ActionChains(driver).context_click(right_click).perform()

    2. 鼠标悬浮

    ActionChains(driver).move_to_element(right_click).perform()

    3. 鼠标双击

    ActionChains(driver).double_click(right_click).perform()

    4. 鼠标拖放

    source = driver.find_element_by_id("XX")
    
    target = driver.find_element_by_id("XX")
    
    ActionChains(driver).drag_and_drop(source , target).perform()

    5. 连续输入框输入内容

    ac =  ActionChains(driver)
    
    t1 = driver.find_element_by_id('t1')
    
    t2 = driver.find_element_by_id('t2')
    
    t3 = driver.find_element_by_id('t3')
    
    ac.click(t1).send_keys('1').click(t2).send_keys('2').click(t2).send_keys('3').perform()
    
    在元素t1 t2 t3里连续输入1 2 3
  • 相关阅读:
    【转】acm小技巧
    poj-1703-Find them, Catch them
    poj-1611-The Suspects
    poj-2236-Wireless Network
    hdu-4496-D-City
    hdu-1213-How Many Tables
    hdu-1856-More is better
    gcd和ex_gcd
    递归趣文
    算法实质【Matrix67】
  • 原文地址:https://www.cnblogs.com/x00479/p/14244151.html
Copyright © 2011-2022 走看看