WPF UI Test Tools

We have been asked by various customers about availability of high-level WPF UI testing tools. We will be distributing WPF test guidance and we’d like to include pointers to all available WPF testing tools, so please do let us know if you have created / used such a tool. See the original post by Karsten here.

Comments (15)

  1. Bruce switzer says:

    if any WPF testing tools or Testing code examples I am very interested in seeing them, as i will be testing WPF app and soon need all the help i can get.


    Bruce Switzer


  2. Ivo says:

    Hi Bruce,

    We are working on a document with guidance on how to test WPF applications, but I don’t think it will be ready for at least a couple of months. In the mean time, we’d be happy to provide guidance on specific issues, so do let us know if you have any specific questions and we’ll try to help.



  3. rakesh says:

    I am trying to get AutomationElement object of the main window of the test app,by using AutomationElement.FromHandle(TestAppProcess.MainWindowHandle)

    This seems to be working when I am excecuting code line by line in debug mode. But If donot to that then TestAppProcess.MainWindowHandle will be 0.

    Even using Thread.Sleep(2000) before accessing MainWindowHandle failed.

    Please let me know if there is another way to create/get AutomationElement of the test App

  4. ivom1 says:


    Instead of a sleep, have you tried using the following:


    Using Sleep is typically a sub-optimal solution, since the wait is not deterministic (you are not waiting on an event) and since it adds unnecessary latency to your application that can quickly build up and result in poor perceived performance. Another way to get the AutomationElement for the main window of your application is by using the following method:

      public AutomationElement FindAutomationElementByName(AutomationElement container, string name)


         Condition c = new PropertyCondition(AutomationElement.NameProperty, name);

         return container.FindFirst(TreeScope.Descendants, c);


    and then calling it as follows:

      AutomationElement ae = FindAutomationElementByName(AutomationElement.RootElement,nameOfYourWindow);

  5. rakesh says:

    Hi ivom

    Thanks for your suggestion.

    I will try this and let you know the result.

    I wanted to register for an automation Event,so that The automation framwork will get notified when ever the is a dialog/form opens in Test App. Also How to know whether that dialog/form is an error dialog?

    Is .Net 3.5 UIAumation is better than 3.0 ?

    Can you please recomend me a link where I can get more samples?



  6. rakesh says:

    Hi Ivom,

    TestAppProcess.WaitForInputIdle is working gr8


  7. ivom1 says:

    Hi Rakesh,

    There are no significant changes in UIAutomation for the .NET framework 3.5 release. Your start point for UIAutomation articles and samples is http://msdn2.microsoft.com/en-us/library/ms753388.aspx.


  8. rakesh says:

    I was able to register for the events using AutomationElement events.

    Is it possible to typecast the AutmationElement object to a .Net class from my code base?

    and How to differenciate between and error window and normal form?

  9. ivom1 says:

    Hmm, not exactly sure what you mean, Rakesh? What are you trying to achieve by typecasting? Typecasting is somewhat of a last resort and there is typically an alternative to it.

  10. rakesh says:

    Hi Ivom,

    Sorry I was not clear,

    What I meant was, If there is a custom control I Have written, And there is an automationelement which corresponds/operates on that control at runtime, How it is possible for me to get a reference of the control which corresponds to my custom control rather than an Automation element object, So that I can do specific operations.

  11. ivom1 says:


    Could you perhaps send me sample code at ivom[at]msn.com?

  12. rakesh says:

    Hi Ivom,

    I have posted a sample application code.

    Please let me know the answer.

  13. Doug R says:

    We’ve tried to use the APIs directly but got stuck on trivial testing issues as waiting for objects etc. Now we’re using a framework that utilizes the UIAutomation APIs (among others) to automate our tests. It has a record/playback feature but all recordings are in pure .NET code. Check it out at http://www.testautomationfx.com. There will be a totally free version as well according to the information we received through the beta program.

    We got through issues like the one Rakesh

    described by just using the classes we want from the framework. For instance the have a WaitForMainWindowHandle that acctually works!! 😉

  14. Rakesh says:

    Hi Ivom,

    I have already addressed most of the issues. But we have many .net 2.0 controls which are not supported by UIAutomation. Do u have any sujjestions?


  15. duncan_bayne says:

    I’ve just released Beta 1.0 of NPresent:


    It’s a simple framework for developing WPF applications test-first using NUnit and NBehave.  It’s still a bit raw, but contributions of code and / or feature requests are always greatly appreciated 🙂