This project is read-only.

Null being returned Intermittently

Mar 26, 2012 at 3:22 AM


I discovered white a few days ago from a codeproject article

Below is the relevant code I'm using to get a comboBox and a button. 50% of the time the code returns null for either the comboBox or the calculateButton or both. Other times its fine. Any ideas?

I'm using Win 7, VS2010 with target framework of .Net 4, downloaded the github sources and built the White.Core.dll.

Thanks a lot



    private static White.Core.Application _application;
    private static White.Core.UIItems.WindowItems.Window _mainWindow;


        string executableSourceFile = @"C:\Windows\system32\calc.exe";
        ProcessStartInfo psi = new ProcessStartInfo(executableSourceFile);
        _application = White.Core.Application.AttachOrLaunch(psi);
        _mainWindow = _application.GetWindow(SearchCriteria.ByText("Calculator"), InitializeOption.NoCache);


      // open the date calculations panel first, then

      ComboBox comboBox =  _mainWindow.Get<ComboBox>(SearchCriteria.ByAutomationId("4003"));
      Button calculateButton = _mainWindow.Get<Button>(SearchCriteria.ByAutomationId("4009"));

Mar 29, 2012 at 4:48 PM
Edited Mar 29, 2012 at 4:49 PM

Almost all controls in Calculator are children of "pane", not the main window.


Panel pane = _mainWindow.Get<Panel>(SearchCriteria.All);

ComboBox comboBox = pane.Get<ComboBox>(SearchCriteria.ByAutomationId("4003"));
            Panel pane = window.Get<Panel>(SearchCriteria.All);
Mar 30, 2012 at 5:15 AM


Thanks for the guidance. Didn't quite do it that way, but all is working perfectly.



Mar 26, 2013 at 4:36 AM
I have the same problem. John, please tell me your solution. I tried everything and still nothing.
Mar 26, 2013 at 4:39 AM
This project has moved to and there is a new NuGet package 'TestStack.White'

White no longer will return null's, instead it will throw, giving you an error message about why it could not find the element. Please swap over to TestStack.White as the old versions are no longer supported
Mar 26, 2013 at 4:42 AM
Edited Mar 26, 2013 at 4:43 AM
I was unclear. I have the same problem in a sense I can not refer to this Combobox. But yes, the exception is thrown. So a big part of this example does not work.

I have the latest version.
Mar 26, 2013 at 5:25 AM
I just grabbed the example code, and installed TestStack.White, it seems to work fine for me.

I will add a few more automated tests around Win32 because it is a gap at the moment, but I need more information to sort it out.
Mar 26, 2013 at 6:12 AM
Edited Mar 26, 2013 at 6:13 AM
Hm. I'll be right back.
Mar 26, 2013 at 6:21 AM
Edited Mar 26, 2013 at 6:27 AM
Yes, you are right. I was transforming that console application to WPF form and forgot to set focus on the Calculator window. By the way, how to do this in the most efficient way? I just did
        var help = _mainWindow.Get<White.Core.UIItems.MenuItems.Menu>(SearchCriteria.ByText("Help"));

I searched API at
but with no success.

A bit noobish questions... =)
Mar 26, 2013 at 6:53 AM
Edited Mar 26, 2013 at 6:54 AM
I just added a test which is the same as the example project at

If that test fails for you, please give me the exception which is thrown.
Mar 26, 2013 at 6:56 AM
The most efficient way is using Automation ID's in WPF.

Please have a look at the same project in the White github repo