views:

88

answers:

1

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?

+2  A: 

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

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

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

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 is an app which can help you get this information without going through the print-outs: http://snoopwpf.codeplex.com/

Lunivore