This is an overly complicated code. You can simply use the dragAndDrop()
method to achieve this in this way -
browser.actions().dragAndDrop(elem, target).perform();
where elem
is the source element and target
is the target element.
Edit 1 : OP mentioned that the webpage is an Angular webpage. I have experienced persistent issues automating this scenario in both Java Bindings, and also using Protractor.
There are several discussion forums, where dragAndDrop
issues have been discussed. One of them is this, another is this.
While the first one is closed and still not sure if it got solved. The latter had a luck with the code mentioned in the post, but my implementation failed to do anything. So I'm not sure if it works.
Also, you can try this repo, where I tried one of the solutions, using a custom JS file to achieve drag and drop in HTML5 for Angular applications.