Silk Test provides general support for WPF and Winforms, which means that all controls included in the .Net framework are supported. The support of a control is on the hand the recognition of that control during recording and on the other hand the provided API for interacting with the control.
Many applications developed in WPF, WinForms are using toolkits which are extending the .Net framework with additional controls. Such controls are named "custom controls", as they are not part of the .Net framework. How Silk Test interacts with those custom controls depends on the parent (from which the control is derived) of the control. For example if the custom control, let's call it ExtendedButton, extends a Button (which is down low in the class-hierarchy) Silk Test will treat it as a normal Button and provides a fair amount of methods (everything from the Button). This provides already a good out-of-the-box support. But many toolkit vendors are locating there controls up in the class-hierarchy, which result is less method support.
In this article the general concept of how to interact with custom controls will be explained. Therefore the XamMonthCalendar from the Infragistics WPF Toolkit http://www.infragistics.com/dotnet/netadvantage/wpf.aspx#Overview will be used as an example, but all the concepts can be aligned for WinForms as well.
The XamMonthCalendar is a custom control that is located up in the class-hierarchy. It derives from the WPFControl and uses many other controls for creating the MonthCalendar, as you can see in Figure 2.
Figure 1: Class Hierarchy – WPFControl
Figure 2: Structure of XamMonthCalendar
When recording against the XamMonthCalendar, Silk Test will use the leaf element of the object tree. For example when selecting the date July, 15th 2010 Silk Test will record a mouse-click on the WPFContentControl with caption=15 and index=1 as there is a WPFContentControl with caption=15 in every month:
(_desktop.WPFWindow("@caption='xamFeatureBrowser'").WPFContentControl("[@caption='15']").Click(MouseButton.Left, New Point(8, 9), ModifierKeys.None)
This recorded action is stable and reliable but not easy to understand.
In Silk Test it is possible to call all the public methods and properties exposed by the control. There are several ways of finding out the public methods and properties of such controls:
- The WPFBase-Class defines the two methods GetDynamicMethodList and GetPropertyList.
- Use the API documentationfrom the toolkit vendor for the XamMonthCalendar:http://help.infragistics.com/Help/NetAdvantage/WPF/2009.2/CLR3.5/html/Infragistics3.Wpf.Editors.v9.2~Infragistics.Windows.Editors.XamMonthCalendar_members.html.
- Use the Object browser in Visual Studio when using .Net controls. In Eclipse, the outline could be used for that, when working with Java controls.
With that information the selection of a specific date could be scripted with the SelectedDate Property:
Figure 3: Excerpt of the XamMonthCalendar API Docu
Calling a public method works with the invoke-method defined on the TestObject. For example:
_desktop.WPFWindow("@caption='xamFeatureBrowser'").WPFControl("[@className='XamMonthCalendar']").Invoke("MouseMove", New Point(10, 10))
Things to remember with Silk Test 2010:
- Only public methods/properties are supported.
- Works only with the WPF TechDomain.
Silk Test 2010 Patch 1 provides the same functionality (of invoking a public method/property of the UI Object) for the WinForms TechDomain in the new Clients (Silk4J, Silk4Net, Workbench), except the methods GetDynamicMethodList and GetPropertyList are not yet supported.
Silk Test 2010 R2 provides the same functionality (of invoking a public method/property of the UI Object) for all the other TechDomains (SWT, Swing, Flex). Details can be found in the online-help of Silk Test.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.