Microsoft UI自动化库与已编码的UI测试 [英] Microsoft UI Automation Library Vs Coded UI Test

查看:129
本文介绍了Microsoft UI自动化库与已编码的UI测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Test Automation之类的东西非常陌生.最近,我已被分配到一个项目,在该项目中,我必须编写一个应用程序(或者我不确定脚本可能是脚本),该应用程序将自动执行类似CAD的WPF应用程序的UI测试,而该应用程序会丢失很多AutomationId

I'm very much new to Test Automation kind of thing. Recently I've been assigned to a project where I have to write an application (or, a script may be, I'm not sure) that will automate the UI testing of a CAD-like WPF application which misses lots of AutomationIds.

在MSDN和其他来源上进行了一些搜索之后,对于我应该使用VS2010中包含的Microsoft UI Automation Library还是新的Coded UI Test功能,我有些困惑.我不清楚这两种情况中的哪一种在哪种情况下适用,一种相对于另一种优势有哪些,以及哪种适合我的目的.

After doing a little searching on MSDN and other sources I'm a bit confused about whether I should use the Microsoft UI Automation Library or the new Coded UI Test feature included in VS2010. I'm not getting the clear picture of which one of these two applies in which scenarios, what advantages one has over the other and which one suits my purpose.

如果您对此事有经验/知识,请遮挡一些灯光.预先感谢.

Please shade some light if you have experience/knowledge on the matter. Thanks in advance.

推荐答案

基本上,Microsoft UIA是.Net 4.0中的新可访问性库. WPF应用程序和控件通过AutomationPeer类具有对UIA的内置支持.

Basically Microsoft UIA is the new accesibility library in .Net 4.0. WPF applications and controls have built-in support for UIA through the AutomationPeer class.

已编码的UI测试是Record&播放自动化工具,使用下面的Microsoft UIA库.与使用C#编写代码相比,由于它是一种工具,因此它可以提高QA效率,以记录更多的测试用例.

Coded-UI test is a Record & Play automation tool which uses the Microsoft UIA Library underneath. Since being a tool compared to writing code in C# it improves QA productivity for recording more test cases.

对于计划中包含自动化支持的应用程序,Coded-Ui应该足够.如果缺少AutomationID,请确保控件具有一些唯一的属性,例如Name.使用UIVerify或Inspect进行检查.

For applications with automation support planned into it, Coded-Ui should be sufficient. If the AutomationIDs are missing make sure the controls have some unique property like Name. Use UIVerify or Inspect to check for this.

如果没有唯一的属性可用,则可以将下面提到的其他技术与Coded-UI结合使用.

If NO unique property is avialble, there are the other below mentioned techniques you can use in combination with Coded-UI.

  • 来自事件 当您的应用程序收到UI自动化事件时,传递给事件处理程序的源对象是AutomationElement.例如,如果您订阅了焦点已更改的事件,则传递给AutomationFocusChangedEventHandler的源是获得焦点的元素.有关更多信息,请参见订阅UI自动化事件.

  • From an Event When your application receives a UI Automation event, the source object passed to your event handler is an AutomationElement. For example, if you have subscribed to focus-changed events, the source passed to your AutomationFocusChangedEventHandler is the element that received the focus. For more information, see Subscribe to UI Automation Events.

从某个点开始: 如果您具有屏幕坐标(例如,光标位置),则可以使用静态的FromPoint方法来检索AutomationElement.

From a Point: If you have screen coordinates (for example, a cursor position), you can retrieve an AutomationElement by using the static FromPoint method.

从窗口句柄: 要从HWND检索AutomationElement,请使用静态的FromHandle方法.

From a Window Handle: To retrieve an AutomationElement from an HWND, use the static FromHandle method.

从集中控制中: 您可以从静态FocusedElement属性中检索表示焦点控件的AutomationElement.

From the Focused Control: You can retrieve an AutomationElement that represents the focused control from the static FocusedElement property.

这篇关于Microsoft UI自动化库与已编码的UI测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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