首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Winapp驱动程序中实现拖放?

如何在Winapp驱动程序中实现拖放?
EN

Stack Overflow用户
提问于 2020-02-25 14:55:37
回答 1查看 114关注 0票数 0

我在Outlook上工作,我需要拖动一封电子邮件并将其放到第二个文件夹中。

我厌倦了下面的代码:

代码语言:javascript
复制
Actions builder = new Actions(driver);
builder.ClickAndHold(from).MoveToElement(to).Release().Build().Perform();
Or
builder.DragAndDrop(from, to).MoveToElement(to).Build().Perform();

有了这个,我可以点击并按住鼠标操作,但电子邮件不会被移动到第二个文件夹中。

EN

回答 1

Stack Overflow用户

发布于 2020-12-11 00:00:48

Next IWebElement DragAndDrop extension working for me:

代码语言:javascript
复制
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();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60389017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档