编码的UI Code First API是否支持拖放? [英] Does Coded UI Code First API support drag and drop?

查看:59
本文介绍了编码的UI Code First API是否支持拖放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,我曾使用Selenium Webdriver来自动化Web UI测试,但是最近我不得不为Sharepoint编写测试。我在使用Selenium时走得很远,但是遇到了必须执行拖放操作的问题。在我的特定情况下,似乎无法拖放该网站。现在,我想看看其他选项,而CodedUI似乎是我的下一个最佳选择。我不想记录测试,而是使用Page对象模型,因此我想使用编码的UI Code first API库。但是我不确定它是否支持拖放。 Google搜索也空了。任何人都可以确认编码的UI Code First API是否支持拖放功能,并且如果将浏览器窗口最小化,它也可以工作吗?这一点也很重要,因为我不希望鼠标实际移动到屏幕上的某个位置并执行拖放操作,因为那样会在打开窗口的情况下维护和运行测试。

I have used Selenium Webdriver in the past for automating my Web UI tests but recently I have to write tests for Sharepoint. I got quite far using Selenium but got stuck at a point where I have to perform Drag and Drop. It seems that in my particular case I can't get drag and drop to work with that site. Now I want to look and other options and CodedUI seems to be the next best option to me. I do not want to record the tests, instead I use the Page object model therefore I want to use Coded UI Code first API library. However I am not sure if it supports drag and drop or not. Google search also came empty. Can anyone please confirm if Coded UI Code First API supports drag and drop and will it also work if the browser window is minimized? This is also important because I don't want the mouse to actually move to a location on screen and perform drag and drop because then it is a pain to maintain and run tests with open windows.

推荐答案

查看他们的文档后,我可以说他们的API不支持拖放。但是您可以通过codedui本机方法拖放自己,并且效果非常好。

After looking at their documentation, i can say that their API don't support drag and drop. But you can do drag and drop yourself by codedui native methods, and it works brilliantly.

找到要通过编码的UI代码第一个API拖动的控件

Find the control which you want to drag by Coded UI Code first API

HtmlControl dragControl = browser.Find<HtmlControl>(new { Id = "DragableControl" });

然后使用codedui本机方法拖动控件。

Then drag the control using codedui native mathods.

Mouse.StartDragging(dragControl);
Mouse.StopDragging(new System.Drawing.Point(100, 100));
// or Mouse.StopDragging(overAnotherControl);

注意:如果将浏览器窗口最小化,它将不起作用。您不能同时运行codedui测试和在计算机上工作。应始终打开被测浏览器/应用程序。我建议您在本地VM或远程VM中运行测试。这样,您可以在VM中启动测试,然后将其最小化并继续在计算机上进行工作。

Note: It won't work if browser window is minimized. You cannot run codedui test and work on your machine at the same time. Browser/Application under test should be opened all the time. I suggest that you either run the test in a local VM or remote VM. In that way, you can fire the test in VM, then minimize it and continue with your work on your machine.

这篇关于编码的UI Code First API是否支持拖放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆