This is an example on how to use TestStack.White to automate a native Windows Application.
White lets us automate (or unit test) an application using C# code. For example, You can send keystrokes and take screenshots:
// send text keystrokes.
window.Keyboard.Enter("Hello World!");
// send key combinations.
window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.HOME);
window.Keyboard.HoldKey(KeyboardInput.SpecialKeys.CONTROL);
window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RIGHT);
window.Keyboard.LeaveKey(KeyboardInput.SpecialKeys.CONTROL);
// take a screenshot.
var textPane = window.Get<TextBox>();
using (var image = textPane.VisibleImage)
{
image.Save("screenshot.png");
}
See the complete example and the White Getting Started Guide.
To automate an application you'd normally need to known its UI tree. For that you can use these tools:
- UIAVerify.
It comes with the Windows SDK and is normally installed at
C:\Program Files (x86)\Windows Kits\8.1\bin\x64\UIAVerify\VisualUIAVerifyNative.exe
. - Spy++.
It comes with Visual Studio and is normally installed at
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\spyxx.exe
(andspyxx_amd64.exe
).
just the edit control:
the entire window: