WPF,项目怀特和Infragistics的

问题描述:

我试图使用项目白来写我的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?

一个通用的答案,我很害怕,但如果白不帮你,你可以使用的位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姓名,那么它​​可能有它的名称相匹配的自动编号:

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让您访问更具体的分量值。您可能会发现它给你你所需要的图案或财产。白色部分是建立在此之上,所以它可以帮助你找出你可以使用的白色成分。例如:

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()

史努比是一个应用程序,它可以帮助您得到这个信息,而无需通过打印输出去:的http:/ /snoopwpf.$c$cplex.com/