Drag & Drop with Protractor by Repeater
Fixed this with the updated changes to protractor. I was missing the .getWebElement() part which replaced the .find() method.
browser.actions().
mouseMove(startPoint.getWebElement(), {x: 0, y: 0}).
mouseDown().
mouseMove(endPoint.getWebElement()).
mouseUp().
perform();
Use .dragAndDrop
method
var moveIndexToIndex = function (startIndex, endIndex) {
return getField(endIndex).then(function (endPoint) {
getField(startIndex).then(function (startPoint) {
// browser.actions().dragAndDrop(startPoint, endPoint).perform(); // doesn't work either
browser.actions().
dragAndDrop(startPoint, {x: (startIndex - endIndex) * 400, y: 0}).
perform();
});
});
});
I'm not sure how you're going to calculate x
and y
. But this is how you usually do it.
As a side note, use $
instead of findElement
. It's being deprecated.
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 @willko747, here was my solution:
browser.actions()
.mouseMove(startPoint.getWebElement(), {x: 0, y: 0})
.mouseDown()
.mouseMove(startPoint.getWebElement(), {x: 5, y: 5}) // Initial move to trigger drag start
.mouseMove(endPoint.getWebElement())
.mouseUp()
.perform();
I think this also solves this issue