web自动化测试(八)---鼠标操作

 

ActionChains——动作链

引入ActionChains类

     from selenium.webdriver.common.action_chains import ActionChains

 

操作

     双击——double_click

     单击——click

     右键——context_click

     悬浮——move_to_element

      拖拽——drag_and_drop

     释放——release

     暂停——pause

 

例子:

      找到元素:

              ele = driver.find_element_by_xpath('//div[@id="u1"]//a[@name="tj_settingicon"]')

      实例化,悬停元素,并停留0.5秒,再点击原来的元素--必须有perform()      【有perform才会执行】

             ActionChains(driver).move_to_element(ele).pause(0.5).click(ele).perform()

 

 

 

     

posted @ 2019-12-15 20:59  太阳-向日葵  阅读(192)  评论(0编辑  收藏  举报