简体   繁体   English

量角器拖动但不下降的元素

[英]Protractor dragging but not dropping element

I am using Protractor for testing my AngularJS application which involves dragging an element and dropping it on a svg. 我正在使用Protractor测试我的AngularJS应用程序,这涉及到将元素拖放到svg上。 I am able to click and drag the element over the svg. 我可以在svg上单击并拖动该元素。

browser.actions()
    .mouseMove(draggableElement)
    .mouseDown()
    .mouseMove({x: 400, y: 100}) //Reaches the svg
    .perform();
browser.sleep(1000);
browser.actions().mouseUp().perform();

As you can notice, after the element is dragged on the svg, I have put a sleep. 如您所见,将元素拖到svg上后,我进入了睡眠状态。 I am able to see the draggable element at the desired position at this point, but it does not get dropped. 我现在可以在所需位置看到可拖动元素,但不会被拖放。 The element disappears suddenly and nothing happens. 该元素突然消失,什么也没有发生。

What is going wrong? 怎么了? Is there a working way in Protractor to correctly drag and drop elements? 在量角器中,有没有一种可以正确拖放元素的工作方式?

I believe you have to pass the draggableEelement also as parameter to mouseDown() and mouseUp() : 我相信您还必须将draggableEelement也作为参数传递给mouseDown()mouseUp()

browser.actions()
  .mouseMove(draggableEelement)
  .mouseDown(draggableEelement)
  .mouseMove({x: 400, y: 100})
  .perform();
browser.sleep(1000);
browser.actions().mouseUp(draggableEelement).perform();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM