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?
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