admin管理员组文章数量:1278653
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?
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?
Share Improve this question edited Apr 10, 2014 at 12:18 Zahid Afaque asked Apr 10, 2014 at 9:40 Zahid AfaqueZahid Afaque 2434 silver badges13 bronze badges 2- 2 Have a look at github./angular/protractor/issues/123 and github./angular/protractor/mit/… – Nicolae Olariu Commented Apr 10, 2014 at 9:44
- @Nicolae Olariu the link (github./angular/protractor/mit/…) you provided work for me – Zahid Afaque Commented Apr 11, 2014 at 11:47
3 Answers
Reset to default 5I had this same issue. The solution for me was to follow the advice in the Selenium issue here: https://code.google./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
you will need to chain your mouse actions:
var yourOffset = {x:5,y:5};
ptor().actions().
mouseMove(yourElement,yourOffset).
mouseDown().
mouseMove(youTarget[,targetOffset]). // [] optional
mouseUp().
perform();
You can use ptor.actions().dragAndDrop(el1, el2).perform();
I have an example here from the test suite in my own application:
/**
* Reorders questions by dragging and dropping.
*/
this.moveQuestion = function (questionToMove, positionToMoveTo) {
return page.getQuestionField(positionToMoveTo).then(function (dest) {
page.getDragHandle(questionToMove).then(function (dragHandle) {
ptor.actions().dragAndDrop(dragHandle, dest).perform();
ptor.sleep(800); // wait for animation
});
});
};
本文标签: javascriptHow to test drag amp drop functionality in AngularJS e2e testingStack Overflow
版权声明:本文标题:javascript - How to test drag & drop functionality in AngularJS e2e testing - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741302097a2371147.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论