我在Outlook上工作,我需要拖动一封电子邮件并将其放到第二个文件夹中。
我厌倦了下面的代码:
Actions builder = new Actions(driver);
builder.ClickAndHold(from).MoveToElement(to).Release().Build().Perform();
Or
builder.DragAndDrop(from, to).MoveToElement(to).Build().Perform();有了这个,我可以点击并按住鼠标操作,但电子邮件不会被移动到第二个文件夹中。
发布于 2020-12-11 00:00:48
Next IWebElement DragAndDrop extension working for me:
public static void DragAndDrop(this IWebElement source, IWebElement destination)
{
var destinationCenterX = destination.Location.X + destination.Size.Width / 2;
var destinationCenterY = destination.Location.Y + destination.Size.Height / 2;
var action = new Actions(source.GetDriver());
action.MoveToElement(source).Build().Perform();
action.ClickAndHold(source).MoveByOffset(destinationCenterX, destinationCenterY).Build().Perform();
destination.Click();
action.Release().Perform();
}https://stackoverflow.com/questions/60389017
复制相似问题