This project is read-only.

How to wait for a window to appear?

Jun 13, 2010 at 9:17 AM

I want to wait until a specific window appears, how can I do this with White?

Do I need to modify the file 'White.Core.dll.config'? Or I can set the timeout property of some class?

Jun 24, 2010 at 10:14 PM
Edited Jun 24, 2010 at 11:48 PM

I have the same question, if not a very similar one.

I'm trying to run automated testing of msiexec, and I need my White tests to wait until the progress window of the installer disappears and the final window appears.

The solution I was able to come up that works for me so far is trap the test into any empty while loop checking to see if the previous window is closed yet.


while (!myWindow.IsClosed)

So the question still remains: is there a way in White testing to wait until a window is closed, or a new window is opened?  Anyone out there that can help? I am fairly content with my solution as it is, but I would much prefer to implement White in this.

Jun 29, 2010 at 7:12 AM


have you read this: WaitHandling

the part for Custom Wait Handling?


You can also use a Delegate for the window.WaitTill funktion and a Timer which checks the element in each step.


Jun 30, 2010 at 5:04 AM
Edited Jun 30, 2010 at 6:40 AM

Actually I found another solution: use basic elements of MS UI Automation to create a 'WinWait' method.

Here is my code:

//This method will check whether the window exist for every 200ms
static public bool WinWait(string windowTitle, int timeOut)
    Stopwatch stopWatch = new Stopwatch();

    while (true)
        //If elapsed time is longer than timeOut value, break the loop and reture false
        if (stopWatch.ElapsedMilliseconds > timeOut)
            return false;

        AutomationElement wantedWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children,
            new PropertyCondition(AutomationElement.NameProperty, windowTitle));

        //If the wanted window exist, break the loop and reture true
        if (wantedWindow != null)
            return true;


I think the White framework should provide an easy way to handle the window waiting problem.

Take a look at an automation script 'AutoIt' (, it's a good example of how to make method names easy to understand.

You can simply read the name of methods and understand it's function: WinExist (check whether a window exist), WinWait, ...

ps: Does anyone have some experience on using AutoIt? I am thinking of whether I should initiate a project, which ports/recreates methods of AutoIt to .NET framework methods using UI Automation framework and Win32 APIs.