Drag and Drop not working using Protractor in HTML5 page

♀尐吖头ヾ 提交于 2019-12-25 16:45:02

问题


I have a scenario where i had to drag and drop the columns. However, i tried below commands but none of them are working

browser.actions().mouseDown(elements).perform();
                browser.actions().mouseMove({x:20, y:120}).perform();
               browser.actions().mouseDown(elements).perform();
                browser.actions().mouseMove({x:20, y:120}).perform();
                browser.actions().mouseUp().perform();

browser.actions().dragAndDrop(elements,{x:20 , y:120}).mouseMove(elements).perform();

 browser.actions().dragAndDrop(elements,a).mouseUp().perform()

The command just highlights the column but doesn't drag to the location.


回答1:


I have seen this answer somewhere else so I share it here as well. (Im not the creator of this function!)

browser.actions().mouseDown(el).perform();
browser.actions().mouseMove({x:0, y:100}).perform();
browser.actions().mouseDown(el).perform();
browser.actions().mouseMove({x:0, y:75}).perform();
browser.actions().mouseUp().perform();



回答2:


if the drag&drop functionality was implemented with HTML5 you need simulate the drag&drop events.

See this solution How to simulate a drag and drop action in protractor in angular2?



来源:https://stackoverflow.com/questions/43933142/drag-and-drop-not-working-using-protractor-in-html5-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!