How to test drag & drop functionality in AngularJS e2e testing

Zahid Afaque picture Zahid Afaque · Apr 10, 2014 · Viewed 7.3k times · Source

I am trying to test my application where I need to move a widget from one location to other, in other word I need to test drag & drop functionality in an end to end test.

How would I test this?

Answer

Brady Isom picture Brady Isom · Aug 6, 2014

I had this same issue. The solution for me was to follow the advice in the Selenium issue here: https://code.google.com/p/selenium/issues/detail?id=3604#c20

Starting with the example from @nilsK, here was my solution:

var yourOffset = {x:5,y:5};
ptor().actions()
    .mouseMove(yourElement,yourOffset)
    .mouseDown()
    .mouseMove(yourElement,{x:0,y:0}) // Initial move to trigger drag start
    .mouseMove(youTarget[,targetOffset]) // [] optional
    .mouseUp()
    .perform();

I think this also solves this issue