[英]How to drag and drop from one coordinate to another C#
I have made a number of tests and I'm using Selenium run them. 我进行了许多测试,并使用Selenium进行了测试。 I need to preform a mouse click on a coordinate and hold the mouse down and release it at a different coordinate. 我需要在一个坐标上单击鼠标,然后按住鼠标并在另一个坐标处释放它。 I have tried using action.DragAndDrop()
but I don't want to select a target element. 我尝试使用action.DragAndDrop()
但我不想选择目标元素。 Is there a way I can just say do a mouse down at a certain coordinate and a mouse up on a different coordinate? 有什么办法可以说是让鼠标在某个坐标上向下移动,而鼠标在另一个坐标上向上移动吗? I would like to do this without having to use Javascript 我想这样做而不必使用Javascript
This is what I am using and works perfectly. 这就是我正在使用的并且运行完美。 You don't need a target element, just the element to move: 您不需要目标元素,只需移动元素即可:
(new Actions(Driver)).DragAndDropToOffset(element, xoffset, yoffset).Perform();
x- and y-offset are simply the int xy coordinates of where you want the element moved to. x-和y-offset只是要将元素移动到的int xy坐标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.