Getting Started with WHITE .NET/WPF Automation Framework

Open Source Published on:
White Framework .Net WPF

Are you a QTP engineer that has often wished there was a way to automated .NET and WPF applications using Visual Studio and C# rather than QuickTest Professional? Do you need to automate a thick client application like WPF, Silverlight, Win32 or WinForms? If so, then WHITE might just be the automation framework for you.

Unlike QTP, which limits you to using VBScript, White allows you to create tests in whichever .NET language you wish — in an IDE that you already use. All this in free open source software — how sweet is that?

Okay. Sounds good so far, but which controls/technologies does it support?

White runs on top of the .NET UI Automation framework. (And just like with QTP, if your application uses third party controls you'll want to verify that WHITE supports them.) White also supports 32 and 64 bit Windows. For more info on what White support check out: Is White the right choice?

Sample .NET Application

I will be using a small .NET sample application I created in Visual Studio 2010 and creatively named.


Before we can start automating our application we'll need a way to spy on the application's fields in order to get the identification properties we'll need to use in order for them to be recognized by WHITE. For this example, I'll use the UI Spy that's installed with the Microsoft Windows SDK. It's located in the \bin folder of the SDK installation path (uispy.exe), or can be accessed from the Start menu (Start\All Programs\Microsoft Windows SDK\Tools\UISpy).

If you start up the test application, then start UI Spy you'll see all the test application's controls in the UI Spy's Control View. The application will be in a tree view. Navigating through the tree view will reveal all your objects along with their properties that can be seen:

Installing the White Automation Framework using Visual Studio

  • First, navigate to the White Downloads page and grab the latest release.
  • Create a folder named White on your local drive and extract the downloaded zip files to it.
  • Open up Visual Studio and create a new .NET Framework 3.5 console application named WHITE.

    • In your new project, go to the Project>Add Reference menu option.
    • Click on Browse and add the White.Core.dll.

  • Add the following namespaces
    using White.Core;
    using White.Core.UIItems;
    using White.Core.UIItems.WindowItems;
    using White.Core.UIItems.WindowStripControls;
    using White.Core.UIItems.MenuItems;
    using White.Core.UIItems.TreeItems;
    using White.Core.UIItems.Finders;
    • To start an application, you must to use the Application.Launch method:
    Application application = Application.Launch(@"D:\Debug\JoeColantonioSampleApp.exe"

    • You can verify that your app has started by using the GetWindow method:


    Window window = application.GetWindow("JoeColantonio.Com Sample .Net App");

    • As with all automation tools, nothing will be very reliable if you don't use some sort of synchronization method to ensure your window/field is active before proceeding. To do this in the WHITE framework, you can use the WaitWhileBusy method:
    • Now we can interact with the fields in our application. Everything in White is a UIItem and has different subclasses that map to corresponding controls. So, to enter text into my application's Patient Name field, I would use the UIItem TextBox control type:
    var patName = window.Get(SearchCriteria.ByAutomationId("txtPatient"));
    • When using WHITE, there are a few methods that can be used to identify objects in your application. The one I use most often is the ByAutomationID.The AutomationID is the programmatic ID assigned by the developer of the application. In Visual Studio this would be the Name property under the Design section:


    The completed script for entering data in all my application's fields looks like this:

    static void Main(string[] args){
      Application application = Application.Launch(@"D:\Debug\JoeColantonioSampleApp.exe");   Window window = application.GetWindow("JoeColantonio.Com Sample .Net App");           window.WaitWhileBusy();
    var patName = window.Get(SearchCriteria.ByAutomationId("txtPatient"));
    var p = window.Get(SearchCriteria.ByAutomationId("cboProvider"));
    p.Select("Crusher, Beverly");
    var dept = window.Get(SearchCriteria.ByAutomationId("cboDepartment"));
    var apptType = window.Get(SearchCriteria.ByAutomationId("cboApptType"));
    var schedType = window.Get(SearchCriteria.ByAutomationId("rdoSchedule"));
    var button = window.Get

    A Simple Example and the Future of White

    This was a simple example to give you a taste of what can be done using the WHITE framework. I'll admit that I haven't tried it on a real-world application so at this stage I'm not sure how robust it really is.

    I also have concerns about how often this open source project is updated. The last release was the August 1, 2011 version 0.21, so development and enhancements for this project have been inactive for some time.

    The good news is there's a good chance that activity will soon increase on WHITE since it was recently acquired by TestStack.

White Framework .Net WPF