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;
    }
}

相关内容

热门资讯

黑科技挂!wepokeai代打... 黑科技挂!wepokeai代打辅助(德扑ai机器人软件开发)果然有挂(有挂教学)-哔哩哔哩;德扑ai...
黑科技ai代打!聚星扑克有假(... 黑科技ai代打!聚星扑克有假(aa poker有外挂吗)果然真的是有挂(有挂规律)-哔哩哔哩,您好,...
黑科技苹果版!德州ai机器人(... 黑科技苹果版!德州ai机器人(wpk最新黑科技)从前存在有挂(有挂规律)-哔哩哔哩1、许多玩家不知道...
黑科技讲解!德州之星有辅助挂(... 您好,德扑ai助手软件这款游戏可以开挂的,确实是有挂的,需要了解加威信【136704302】很多玩家...
黑科技插件!微扑克如何让系统发... 黑科技插件!微扑克如何让系统发好牌(aa poker有外挂吗)果然有挂(有挂详情)-哔哩哔哩1、微扑...
黑科技教学!aapoker有外... 黑科技教学!aapoker有外挂(aapoker辅助工具ai)往昔真的有挂(有挂教学)-哔哩哔哩1、...
黑科技总结!wepoke辅助挂... 黑科技总结!wepoke辅助挂(wepoke智能ai)原生存在有挂(有挂攻略)-哔哩哔哩1、wepo...
黑科技私人局!来玩app德州扑... 黑科技私人局!来玩app德州扑克(aa poker有外挂吗)从前存在有挂(今日头条)-哔哩哔哩是一款...
黑科技好友!wepoke有透视... 自定义aa poker有外挂吗系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助...
黑科技有挂!云扑克辅助器是真是... 黑科技有挂!云扑克辅助器是真是假(aapoker真的有猫腻吗)一贯真的是有挂(有挂细节)-哔哩哔哩1...