selenium drag_and_drop_by_offset()拖拽不生效问题解决

drag_and_drop_by_offset(源, xoffset , yoffset )
source:鼠标按下的元素

xoffset:要移动到的 X 偏移量

yoffset:要移动到的 Y 偏移量

url_drag = 'file:///D:/%E8%AF%BE%E5%A0%82%E8%B5%84%E6%96%99/14drag.html'
driver.get(url_drag)
el5 = driver.find_element(By.XPATH, '//*[@id="div2"]')
actions.click_and_hold(el5).perform() # 先用鼠标按住需要拖动的元素,不松开
actions.drag_and_drop_by_offset(el5,500, 500).perform() # 然后再进行元素的拖动

你可能感兴趣的:(测试辅助+问题处理,selenium,测试工具,学习,python)