Skip to main content
1 of 3

TestStack White: (partial open-source)

White is an open-source framework for automating rich client applications based on Win32, WinForms, WPF, Silverlight and SWT (Java) platforms. It is .NET based and does not require the use of any proprietary scripting languages. Tests/automation programs using White can be written with whatever .NET language, IDE and tools you are already using. White provides a consistent object-oriented API, hiding the complexity of Microsoft's UIAutomation library (on which White is based) and windows messages.

With the free Visual Studio Express you can create automated tests with the .Net framework. See my example console C# app code to automate notepad.exe below:

using System;
using TestStack.White;
using TestStack.White.InputDevices;
using TestStack.White.UIItems.Finders;
using TestStack.White.UIItems.MenuItems;
using TestStack.White.UIItems.WindowItems;

namespace WhiteTest
{
    class Program {
        static void Main(string[] args) {
            Tests tests = new Tests();
            tests.Notepad();
        }
    }

    class Tests {
        public void Notepad() {
            Application app = Application.Launch("notepad.exe");
            Window window = app.GetWindow("Untitled - Notepad");

            // Change text
            var box = window.Get(SearchCriteria.ByClassName("Edit"));
            Keyboard.Instance.Send("test", box);

            // Save
            window.MenuBar.MenuItem("File", "Save As...").Click();
            var filename = window.Get(SearchCriteria.ByClassName("Edit"));
            Keyboard.Instance.Send(DateTime.Now.ToString("yyyyMMddHHmmssffff") + "test.txt", filename);
            window.Get(SearchCriteria.ByText("Save")).Click();
            
            app.Kill();
            
            // Assert file is created in Documents folder
            // etc...
        }
    }
}