SWITCHTO方法codeD UI [英] SwitchTo method for Coded UI

查看:288
本文介绍了SWITCHTO方法codeD UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作一,手codeD,一个应用程序codeD UI测试。

I am working on a, hand coded, Coded UI test for an application.

的应用程序具有在2个窗口操作的特定功能。当点击一个按钮,将出现一个新的窗口,然后在用户进行选择在其上的窗口关闭,然后用户继续在主窗口上采取行动。

The application has a certain function that operates in 2 windows. When a button is clicked, a new window appears and then the user makes a selection upon which that window closes, and then the user continues taking actions on the main window.

随着硒,我会处理,通过在所有的窗口句柄迭代和交换通过它传递我想用网页的URL driver.SwitchTo()。窗口(句柄) 方法。然而,codeD UI,我还没有找到一个类似的解决方案。使用Process类我可以做同样的事情,可以工作:

With Selenium, I would handle that by iterating through all the window handles and switching by using passing it the URL of the page I wanted using the "driver.SwitchTo().Window(handle)" method. However, with Coded UI, I have not found a similar solution. Using the Process class I can do something similar that could work:

Process[] myList = Process.GetProcessesByName("iexplore");
foreach (Process item in myList)
if (item.MainWindowTitle.Contains("Window Title"))
{
item.Kill();
}

问题是,我测试的应用程序设计不当和整个应用程序的所有窗口的名称相同,因此将无法工作。

The problem is that the application that I am testing is poorly designed and all windows throughout the application have the same name, thus it will not work.

有没有可用于切换到上codeD UI不同的窗口的方法?或者,这将是最好的方法?

Is there a method which can be used to switch to a different window on Coded UI? Or what would be the best approach?

推荐答案

看看这个问题,它可以帮助:<一href=\"http://stackoverflow.com/questions/23522114/interacting-with-multiple-instances-of-an-application-in-$c$cd-ui\">Interacting与

Take a look at this question, it might help: Interacting with multiple instances of an application in Coded UI

您不CUIT做调包,每个窗口和控制通过一个UITestControl对象访问。如果你想要做一个其他窗口上的东西,你为它创建一个新的对象。如果你不能与搜索属性区分这两个窗口,你可以使用实例属性或 FindMatchingControls 方法。

You don't do "switching" in CUIT, every window and control is accessed via a UITestControl object. If you want to do stuff on an other window you create a new object for it. If you can't differentiate the two windows with search properties you can use the Instance property or FindMatchingControls method.

要抓住你可以使用一个winhook窗口创建活动。它可以让你创建的每个窗口的窗口句柄。使用您可以找出创建的窗口是你正在等待窗口,然后使用 UITestControlFactory.FromWindowHandle 以创建为CUIT了交互的UITestControl。如果您有该窗口生成的类,你可以创建一个类的实例,并调用它的的copyfrom 方法传递给它,你从窗口句柄创建控件。

To catch a window creation event you can use a winhook. It gives you the window handle of every window created. Using that you can find out if the window created is the window you are waiting for and then use the UITestControlFactory.FromWindowHandle to create a UITestControl for CUIT to interact with. If you have a generated class for that window you can create an instance of that class and call its CopyFrom method to pass to it the control you created from the window handle.

这篇关于SWITCHTO方法codeD UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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