Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 2.55 KB

File metadata and controls

50 lines (40 loc) · 2.55 KB
layout layout
title Getting started with White
order 1

Pre-requisites

.NET 4.0 framework

Getting Started

  1. Install via NuGet
    > install-package TestStack.White
  2. Have a look at the WPF or WinForms sample projects
  3. Have a look at Whites UI Tests, White has automated tests for most controls to prevent regressions in the codebase. These serve as a great example of how to automate different controls. See White's UI Tests
  4. Download http://uiautomationverify.codeplex.com/ which is an ESSENTIAL tool when doing UI Automation work.
  5. Start writing tests, first off you require a unit testing framework like xUnit or nUnit. See below for a basic walkthrough
  6. Join the mailing list at https://groups.google.com/forum/#!forum/teststack_white
  7. Report issues at https://github.com/TestStack/White/issues?state=open
  8. If you would like to contribute back, read Contributing to learn how to get started contributing back!

Writing your first test

Start off with an empty test stub

[Fact]
public void MyFirstUITest() { }

Get hold of a window

Application application = Application.Launch("foo.exe");  
Window window = application.GetWindow("bar", InitializeOption.NoCache);

White uses the UI Automation API (UIA) to find controls on a window. UIA communicates to a displayed window via window messages. This find is performed by iterating through all the controls in a window.

Finding a UI Item and performing action

Button button = window.Get<Button>("save");
button.Click();

Finding a UIItem based on SearchCriteria

SearchCriteria searchCriteria =     SearchCriteria.ByAutomationId("name").AndControlType(typeof(TextBox)).AndIndex(2);
TextBox textBox = (TextBox) window.Get(searchCriteria);
textBox.Text = "Anil";

Reporting Issues

When reporting issues please include the following information:

  • The target framework (WPF, Winforms etc)
  • The version of White you are using
  • [Recommended] A failing test! or
  • [Recommended] A Gist with the code which is failing

The more information the better, we accept pull requests with failing tests and pull requests which fix the issue too!