TestComplete 5 Sneak Peak: Support for WPF Controls
Test and Monitor | Posted October 31, 2006

Since both TestComplete and Windows Vista are currently under development, the information contained in this article is not final and may change at any time, without notice.

Windows Vista, the next generation of the Windows operating system from the Redmond guys, includes a lot of new features and technologies like .NET Framework 3 and Windows Presentation Foundation (WPF).

To create WPF applications, Microsoft has developed a new Extensible Application Markup Language (XAML). Many developers are now using WPF (XAML) controls to develop their software products, while leaders of quality assurance departments are busy looking for new automated testing tools that support Microsoft's newest technologies.

Full-scale support for WPF controls is coming soon in the next version of our powerful automated test manager – TestComplete 5.

Version 5 includes the WPF Controls Support Plug-in that allows TestComplete to detect XAML (WPF) windows and controls. If a window or control is XAML, the plug-in exposes methods and properties of this window (or control) to TestComplete. The plug-in provides access to private, protected and public fields, properties and methods of the controls. The plug-in actually makes WPF applications “open” to TestComplete without any effort on the part of the application developer.

The support provided to WPF controls is similar to the support provided for Win32 controls and objects of Open Applications. TestComplete automatically associates specific program objects with XAML controls. Each of these program objects contain the exposed methods and properties as well as a number of specific properties and methods added by TestComplete for the control. Using these specific methods and properties, you can, for instance, select or unselect items in a list box, or check or uncheck items in a menu.

Currently, you can use the following program objects to work with XAML controls:

  • WPFButton
  • WPFCheckBox
  • WPFComboBox
  • WPFEdit
  • WPFExpander
  • WPFListBox
  • WPFMenu
  • WPFRadioButton
  • WPFRepeatButton
  • WPFScrollBar
  • WPFScrollViewer
  • WPFTabControl
  • WPFToggleButton
  • WPFToolBar
  • WPFTrackBar

(This list may be changed and expanded in future versions).

TestComplete uses a special WPFObject method to address windows and controls exposed through the WPF Controls Support plug-in. You can also record fully functional scripts over WPF controls.

To demonstrate how TestComplete 5 interacts with an application based on WPF controls, we will look at the AvalonCalculator sample shipped with standard samples for Windows Vista SDK. The following screenshot displays the AvalonCalculator window:

To demonstrate TestComplete's functionality, we need the WPF Controls Support and .NET Open Applications Support plug-ins installed and enabled:

Click to display image

To demonstrate TestComplete's recording abilities, we will record a small script that multiplies 123 by 456 and calls the Help | About dialog window.

Run the Avalon Calculator, start recording and perform the recording as you normally would.

The recorded script is as follows:

Now let's make sure that the Avalon Calculator can correctly multiply numbers. We will try to multiply 500 by 125 and check the result:

The resultant code does the following:

  • Simulates mouse clicks over calculator buttons.
  • Obtains the result from the calculator's edit box (we address the edit box using the WPFObject("MyTextBox") statement and get the text using the Text property).
  • Compares the text of the 500*125 multiplication.

After the script is executed, the following log is created:

Click to display image

While working on this feature, we tried to develop support for WPF controls so that it was similar to Win32 and WinForms control support. We hope this goal has been achieved. After TestComplete 5 is released, automated testing of applications that use WPF controls should no longer be a problem.