WPF, Project White and Infragistics

你离开我真会死。 提交于 2019-12-22 10:46:02

问题


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?


回答1:


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/



来源:https://stackoverflow.com/questions/2920593/wpf-project-white-and-infragistics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!