为编码的UI测试发布WPF自定义控件属性 [英] Publish WPF custom control properties for Coded UI Tests

查看:108
本文介绍了为编码的UI测试发布WPF自定义控件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写WPF自定义控件。现在,我想发布一些重要的属性,用于编码用户界面测试目的。我的问题是我不知道怎么做,因为我不能使用自动化提供商(例如IValueProvider  - 他们
都不符合我的需求)

I'm writing a WPF custom control. Now I wanna publish some important properties for Coded UI testing purpose. My problem is that I do not know how to do it because I can not use the Automation providers (e.g. like IValueProvider - they all don't fit my needs)

我看了  Gautam Goenka的"关于编码UI测试可扩展性的系列" ( http://blogs.msdn .com / b / gautamg / archive / 2010/01/05 / series-on-coded-ui-test-extensibility.aspx
- 非常好的顺便说一句)并评估了一些代码示例(NumericUpDown) ,Excel,...)

I read the  Gautam Goenka's "Series on Coded UI Test Extensibility" (http://blogs.msdn.com/b/gautamg/archive/2010/01/05/series-on-coded-ui-test-extensibility.aspx - very good by the way) and evaluated some code examples (NumericUpDown, Excel,...)

我实现了一个UITestExtensionPackage和一个UITestPropertyProvider但是在UITestPropertyProvider的GetPropertyValue方法中我不知道如何获取主控制实例并获取(或设置)特殊属性。

I implemented a UITestExtensionPackage and a UITestPropertyProvider but in the UITestPropertyProvider's GetPropertyValue method I don't know how to get the main control instance and get (or set) the special properties.

任何帮助将不胜感激!

谢谢

Michael

推荐答案

如果您想要掌握AutomationElement,可以通过以下方式实现。(也可以尝试使用类似的SetPropertyValue。

If you are looking to get hold of the AutomationElement, you can do it by the following fashion.(Try a similar thing for SetPropertyValue as well.

public abstract 对象GetPropertyValue(UITestControl uiTestControl,
< span style ="color:blue"> string propertyName)

public abstract Object GetPropertyValue(UITestControl uiTestControl, string propertyName)

{

AutomationElement automationElement =(AutomationElement)uiTestControl.NativeElement;

AutomationElement automationElement = (AutomationElement) uiTestControl.NativeElement;

// /您的代码

}


这篇关于为编码的UI测试发布WPF自定义控件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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