使用Dragula在应用程序中拖放WebDriver [英] WebDriver Drag and Drop in application using Dragula

查看:118
本文介绍了使用Dragula在应用程序中拖放WebDriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司有一个包含拖放功能的新应用程序.拖放是通过Dragula库完成的.

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

我正在尝试自动化此功能,但是我没有任何运气.我已经尝试了两个WebDriver内置的DragAndDrop()方法(据我了解,这在现代Web技术中通常无法正常工作).我尝试用动作构造自己的拖放.而且我也尝试在javascript执行器中使用jquery.这两种方法均无效.

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.

有人有什么建议吗?

推荐答案

如果DragAndDrop()方法不起作用,则可以使用

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();

这将垂直和水平滚动.

这篇关于使用Dragula在应用程序中拖放WebDriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆