Atata框架:DragAndDrop不起作用
创始人
2024-09-21 11:30:55
0

在Atata框架中执行Drag-and-Drop操作的最佳方法是使用Atata提供的DragAndDrop扩展方法。以下是如何使用它:

using Atata;
using NUnit.Framework;

namespace SampleApp.UITests
{
    public class DragAndDropTests : UITestFixture
    {
        [Test]
        public void DragAndDrop()
        {
            Go.To<DragAndDropPage>();

            var sourceElement = Go.To<DraggableElementPage>().DraggableElement;
            var targetElement = Go.To<DroppableElementPage>().DroppableElement;

            // Perform the Drag-and-Drop operation
            sourceElement.DragAndDrop(targetElement);

            // Verify that the operation was successful
            sourceElement.Should.Not.Exist();
            targetElement.Should.Equal("Dropped!");
        }
    }

    [Url("https://jqueryui.com/droppable/")]
    [VerifyTitle]
    public class DragAndDropPage : Page
    {
    }

    public class DraggableElementPage : Page
    {
        [FindById("draggable")]
        public DraggableObject<DroppableElementPage> DraggableElement { get; private set; }
    }

    public class DroppableElementPage : Page
    {
        [FindById("droppable", OuterXPath = "")]
        public Content<DroppableElementPage> DroppableElement { get; private set; }

        public UIComponent<DroppableElementPage> DroppedObject =>
            Find<UIComponent<DroppableElementPage>>(By.XPath(".//p[text()='Dropped!']"));
    }

    public class DraggableObject<TDroppable> : Content<TDroppable>, IDraggable<TDroppable>
        where TDroppable : PageObject<TDroppable>
    {
        private Config<IDraggable<TDroppable>> drag;

        public DraggableObject(PageObject<TDroppable> owner)
            : base(owner)
        {
            drag = new Config<IDraggable<TDroppable>>(this);
        }

        public TDroppable DragAndDrop(TDroppable droppable)
        {
            ExecuteActions(actions => actions.DragAndDropToElement(droppable.Scope));
            return droppable;
        }

        public Config<IDraggable<TDroppable>> Drag => drag;
    }
}

相关内容

热门资讯

第9分钟辅助!开心泉州辅助器(... 开心泉州辅助器 无需打开直接搜索微信:136704302本司针对手游进行,选择我们的四大理由: 1、...
每日必看教程!约局吧辅助器,a... 每日必看教程!约局吧辅助器,aapoker怎么提高中牌率,大神讲解(一直真的有挂)-哔哩哔哩;1、这...
第七分钟讲解!未来云南辅助(辅... 大家好,今天小编来为大家解答未来云南辅助这个问题咨询软件客服可以免费测试直接加微信(13670430...
透视苹果版!wepoker辅助... 【福星临门,好运相随】;透视苹果版!wepoker辅助是真的吗,约局吧是否有挂,2026新版技巧(一...
5分钟发现!福建十三水辅助器价... 5分钟发现!福建十三水辅助器价格(辅助挂)原来是有挂(AA德州教程!开挂辅助插件);打开点击测试直接...
玩家必看!菠萝辅助器免费版的特... 《玩家必看!菠萝辅助器免费版的特点,hhpoker辅助软件下载,2026新版技巧(果然有挂)-哔哩哔...
第八分钟讲究!浙江宝宝游戏辅助... 浙江宝宝游戏辅助器开挂教程视频分享装挂详细步骤在当今的网络游戏中,浙江宝宝游戏辅助器作为一种经典的娱...
技术分享!wepokerplu... 技术分享!wepokerplus辅助,hh poker辅助器先试用,2026新版技巧(一贯有挂)-哔...
第8分钟辅助!微信微乐辅助io... 微信微乐辅助ios 无需打开直接搜索微信:136704302本司针对手游进行,选择我们的四大理由: ...
重大通报!aapoker怎么设... 重大通报!aapoker怎么设置提高好牌几率,如何下载wpk透视版,玩家教你(一贯是有挂)-哔哩哔哩...