White official homepage: http://teststack.github.com/White/
Now we have changed to TestStack. White. It seems that we will be commercialized soon.
UIA & UISpy
White is written based on Microsoft's UIA (UI automation). Microsoft's UIA is a subsidiary of ms accessibility and is included in. net framework 3.0. In. in net framework 3.0, there is a UIA-related tool UISpy, which is more friendly than the Spy interface and used to obtain control information, But the strange thing is that, microsoft in. net framework 3.5 does not automatically contain this tool. You can re-download and install it yourself:
UISpy: http://www.microsoft.com/downloads/en/details.aspx? Familyid = 4377F86D-C913-4B5C-B87E-EF72E5B4E065 & displaylang = en,
Before installation, make sure that you have the following two registry key values:
HKLM/SOFTWARE/Microsft/Microsoft SDKs/Windows/CurrentInstallFolder
HKLM/SOFTWARE/Microsft/Microsoft SDKs/Windows/CurrentVersion
(If you are currently installing. net 3.5, the UISpy ++ installation package will change the two key values to v6.0, so remember to change them back to v6.0A)
An Introduction to UIA: http://msdn.microsoft.com/en-us/magazine/cc163288.aspx
Simple use of White
White fully supports standard. net controls, while other controls can be extended using the CustomUIItem defined in White. Although UISpy ++ is included in. net 3.0, it does not fully recognize standard controls, so it is best to use the LogStructure () method to get the information inside the control: http://white.codeplex.com/wikipage? Title = Third % 20 Party % 20 Controls & referringTitle = Home
After the White file is downloaded, create a Test Project and reference the White. Core. dll file. Common namespaces include:
White. Core. UIItems: contains common control classes except the Window class.
White. Core. UIItems. WindowsItems: Contains windows and other classes.
White. Core. InputDevices: includes Keyboard, Mouse, AttachedKeyboard, AttachedMouse, and other classes.
White. Core. UIItems. Finders: contains the SearchCondition and searchcriders classes that define the search control conditions.
White. Core. WindowsAPI: enumeration class KeyboardInput. SpecialKeys that contains special buttons
using White.Core.InputDevices; using White.Core.UIItems.WindowItems; using White.Core.WindowsAPI; using White.Core.UIItems; using White.Core.UIItems.Finders;
Start a program:
White.Core.Application app = White.Core.Application.Launch(appPath); //or attach to the launched application White.Core.Application app = White.Core.Application.Attach(appPid);
Get a window titled "Getting Started:
Window mainWin = app.GetWindow("Getting Started");
Similarly, we can see that the textbox and name attributes of "File name:" In this window are "OK" buttons :;
TextBox fileNameEdit = mainWin.Get<TextBox>("File name:"); Button okBtn = mainWin.Get<Button>("OK");
Or use the SearchCriteria enumeration class:
TextBox fileNameEdit=(TextBox)mainWin.Get(SearchCriteria.ByText("File name:")); Button okBtn=(Button)mainWin.Get(SearchCriteria.ByText("OK"));
Keyboard input:
In White, if you want to perform keyboard or mouse operations on a control, attached the control first. If you want to enter the combination key, Hold the special key first, and then belong to the general primary key, release a special key
//attach to mainWin firstly AttachedKeyboard keyboard = mainWin.Keyboard; //Press key 'a' keyboard.Enter("a"); //input combination keys like: Alt + S //hold 'Alt' key firstly, then enter 's', release 'Alt'//e.g. input 'Alt + S' on mainWin keyboard.HoldKey(KeyboardInput.SpecialKeys.ALT); keyboard.Enter("S"); keyboard.LeaveKey(KeyboardInput.SpecialKeys.ALT);
With the above basic APIs, you can write some simple automated test code. For more details, refer to the White homepage.