御命丹心

萧瑟悲声秋风起,刹忆寒蝉未鸣时

导航

滑动处理

#点击元素拖动
def click_move(by,locator,value):
    try:
        source = get_element(driver,by,locator)  # 需要滑动的元素
        action = ActionChains(driver)
        action.click_and_hold(source).perform()  # 鼠标左键按下不放
        action.reset_actions()  # 清除之前的action

        distance = value #滑动距离
        track = get_track(distance) #循环执行

        for i in track:
            action.move_by_offset(xoffset=i, yoffset=0).perform()
            action.reset_actions()
        sleep(1)
        action.release().perform()  # 释放鼠标
        sleep(1)
    except Exception as e:
        print(e)

 

posted on 2020-07-10 19:37  正法  阅读(164)  评论(0编辑  收藏  举报