Automation of WPF applications

Last Updated on by

Post summary: Overview how to successfully automate WPF application with Telerik Testing Framework and TestStack White.

I’ve spent lots of time in automation of a WPF application. Nowadays world is dealing with web application and desktop application are fading away. Nevertheless desktop applications still has their own private space and I hope those series of posts will be useful to someone.


Application under test is created with WPF but has WinFoms grids included on different windows presenting lots of information. Performance is the main reason to use WinFoms grids inside a WPF application. WPF grid with 40 columns and 100 rows lags a lot. After research and proof of concept on commercial and open source tools and frameworks two were chosen: Telerik Testing Framework and TestStack White. They provide flexibility and maintainability which is so vital in fast changing application. Both are used with C#. Every one has its own weaknesses and strengths but both made a perfect synergy to provide you possibility to automate almost everything.

Telerik Testing Framework

Extremely powerful and free to use framework. You can purchase additionally support which is at reasonable prices. Telerik also provide Test Studio, a tool and MS Visual Studio plug-in, build on top of the framework. This is also an option, but for me using a tool gives more restrictions than benefits. Their framework is the best available for testing WPF applications. It is very easy to use. Elements are easily located by XamlPath (very similar to XPath). Of course there are other locate options. Framework provides very rich API with lots of operations over the elements. Still its powerfulness is limited to WPF. It is not that good with WinForms elements. Telerik Testing Framework requires installation as it copies lots of assemblies in GAC.

TestStack White

Extremely powerful open source framework. Build as a wrapper of Microsoft UI Automation framework you can automate almost everything with it. But this comes at a price. It is hard to locate elements. I use it only where Telerik Testing Framework is not capable to do the work – WinForm grids, context menus, closing windows with small X in the top right corner?! Yes, those are WPF inside, but are hosted in operation system window and Telerik has no access to it.

In GitHub I have uploaded a MS Visual Studio 2013 project with very simple application taken from this example. I have added very basic tests to it to illustrate how it is done. With upcoming posts I’ll explain in details the idea and implementation.

Bellow is list of posts included in the series:

  1. Introduction (current post)
  2. WPF automation – projects structure
  3. WPF automation – locating and structure of WPF elements
  4. WPF automation – locating and structure of WinForms elements
  5. WPF automation – using the elements
  6. WPF automation – running the tests
If you find this post useful, please share it to reach more people. Sharing is caring!
Share on FacebookShare on LinkedInTweet about this on TwitterShare on Google+Email this to someone