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.
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.
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() {
// Arrange
Application app = Application.Launch("notepad.exe");
Window window = app.GetWindow("Untitled - Notepad");
// Act
var box = window.Get(SearchCriteria.ByClassName("Edit"));
Keyboard.Instance.Send("test", box);
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
}
}
}
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() {
// Arrange
Application app = Application.Launch("notepad.exe");
Window window = app.GetWindow("Untitled - Notepad");
// Act
var box = window.Get(SearchCriteria.ByClassName("Edit"));
Keyboard.Instance.Send("test", box);
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
}
}
}