Our vBulletin migration is complete.
Welcome vBulletin users! All content and user information from the Micro Focus Forums (vBulletin) site has been migrated to this site. READ MORE.

.Net Custom controls

Joachim_Herschmann Absent Member.
Absent Member.
0 1 2,649

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'][1]").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:

  1. The WPFBase-Class defines the two methods GetDynamicMethodList and GetPropertyList.
  2. 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.
  3. 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:

    _desktop.WPFWindow("@caption='xamFeatureBrowser'").WPFControl("[@className='XamMonthCalendar']").SetProperty("SelectedDate", Date.Parse("2010-06-15")


    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.

1 Comment
shwetamber Absent Member.
Absent Member.

How to add these infragistics class library in silk test solution ?  

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.