简体   繁体   English

如何从一个坐标拖放到另一C#

[英]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.

相关问题 C# 从一个图片框拖放到另一个图片框 - C# Drag and Drop from one Picture box into Another 如何在C#中将文件夹/文件从一个Windows资源管理器拖放到另一个Windows资源管理器? - How to drag and drop folders/files from One Windows Explorer to another windows explorer in C#? 如何通过拖放将列表视图项从一个列表移动到另一个列表? UWP C# - How to move List View Item from one list to another with drag and drop? UWP C# 如何在C#中将一个图片拖放到另一个图片框中的另一个图片上方的图片框中? - How to drag and drop one image in a picture box on top of another in another picturebox in C#? C#将一个图片框拖放到另一个图片框中 - C# Drag and Drop one picture box into another picture box 从另一个应用程序拖放C#Windows Form应用程序 - Drag And Drop C# Windows Form Application From another Application 如何在C#中将单词从文本框中拖放到另一个特定位置 - how to drag and drop a word from a textbox into another at a particular location in c# 如何将一个项目从一个列表框拖放到另一个 - how to do drag and drop an item from one listbox to another 如何禁用拖放行从一个datagridview到另一个? - How to disable drag drop row from one datagridview to another? 如何从一个面板拖放(复制)到另一个面板 - How to Drag and Drop(copy) from one panel to another panel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM