WPF、Project White 和 Infragistics [英] WPF, Project White and Infragistics

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

问题描述

我正在尝试使用 Project White 为我的 WPF 应用程序编写自动化测试.在我尝试与 Infragistics 控件交互之前,一切都很顺利.有没有人对此设置有任何经验,您能否发布一个示例,说明我如何(例如)与 XamRibbon 或 XamOutlookBar 交互?

I am trying to use Project White to write automated tests for my WPF application. It is all going well until I try to interact with Infragistics controls. Has anyone had any experience of this set up and would you be able to post an example of how I can (for example) interact with the XamRibbon or XamOutlookBar?

推荐答案

恐怕有点笼统,但如果 White 没有帮助你,你可以直接使用 Microsoft UI 自动化.

Bit of a generic answer I'm afraid, but if White isn't helping you, you can use Microsoft UI Automation directly.

首先,找到您的控件.如果它有一个 WPF名称",那么它可能有一个与名称匹配的自动化 ID:

First, find your control. If it's got a WPF "Name" then it probably has an automation id which matches the name:

AutomationElement element = AutomationElement.Root.FindFirst(
    TreeScope.Descendants,
    new PropertyCondition(AutomationElement.AutomationIdProperty, <whatever>))

您也可以使用 NameProperty 之类的东西,它主要映射到文本或标题,或者 ControlTypeProperty 或 ClassProperty.您可以随时使用 FindAll 为您提供有关可用控件的更多信息.

Alternatively you can use things like the NameProperty, which mostly maps to text or titles, or the ControlTypeProperty or ClassProperty. You can always use FindAll to give you more information about the controls available.

找到控件后,打印出其支持的模式和属性:

When you find your control, print out its supported patterns and properties:

element.GetSupportedPatterns()
element.GetSupportedProperties()

属性返回信息.这些模式类似于 ListItemPattern、GridPattern,让您可以访问更多特定于组件的值.您可能会找到一种模式或属性,它可以满足您的需求.White 部分建立在此之上,因此它可能会帮助您找出可以使用哪些 White 组件.例如:

The properties give back information. The patterns are things like ListItemPattern, GridPattern and let you access more component-specific values. You may find a pattern or property which gives you what you need. White is partly built on top of this, so it might help you find out which White components you could use. For instance:

((TogglePattern)Element.GetCurrentPattern(TogglePattern.Pattern)).Toggle()

Snoop 是一款无需打印即可帮助您获取此信息的应用程序:http://snoopwpf.codeplex.com/

Snoop is an app which can help you get this information without going through the print-outs: http://snoopwpf.codeplex.com/

这篇关于WPF、Project White 和 Infragistics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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