WebDriver Drag and Drop in application using Dragula

蓝咒 提交于 2019-12-07 20:36:53

问题


My company has a new application that incorporates drag and drop. The drag and drop is done via the Dragula library.

I'm trying to automate this functionality, but I'm not having any luck. I have tried both WebDriver's built in DragAndDrop() method (which my understanding is it doesn't normally work so well with modern web tech). I tried constructing my own Drag and Drop with Actions. And I've also tried using jquery in the javascript executor. Neither of these methods have worked.

Anyone have any suggestions?


回答1:


If DragAndDrop() method didn't work for you can build your own using other methods from Actions

IWebElement source;
IWebElement target;

Actions actions = new Actions(driver);
actions.ClickAndHold(source).Perform();
actions.MoveByOffset(target.Location.X - source.Location.X, target.Location.Y - source.Location.Y).Perform();
actions.Release(target).Perform();

This will scroll vertically and horizontally.



来源:https://stackoverflow.com/questions/41622263/webdriver-drag-and-drop-in-application-using-dragula

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!