Search code examples
visual-studio-2012coded-ui-testsgui-testingwindow-handles

Coded UI Test - waiting for running application to finish during the test


I am trying to create test for my-app using coded ui test with visual studio ultimate 2012, in my-app i run another app ( cmd window is opened during "another app" running). i want to wait until this "another app" finish running and then to check some results. how can i do that?

if someone know how to control window using coded ui test i think it may help, until now i didn't find an example of that!


Solution

  • i find a way.

    my problem was to control and wait for the cmd window which related to "another app" execution.

    i run the system and the VS recorder, and start recording when cmd window of the another app pop up and then i maximized the window and stop recording, i did this to get automatic generated code to control this window, the code i got:

        public void WaitUntilAnotherappFinish()
        {
            #region Variable Declarations
            WinWindow uIAnotherppWindow = this.UIAnotherappWindow
            #endregion
    
            // Maximize window 
            uIAnotherppWindow.Maximized = this.WaitUntilAnotherappFinishParams.UIAnotherappWindowMaximized;
        }
    

    so i replace the maximize window command line to waiting for the window not exist:

        public void WaitUntilAnotherappFinish()
        {
            #region Variable Declarations
            WinWindow uIAnotherppWindow = this.UIAnotherappWindow
            #endregion
    
            // wait for window to close 
            uIAnotherppWindow.WaitForControlNotExist();
        }
    

    and this exactly did what i want :).

    important note: be careful that this file is an auto generated file so your changes may be undo! solve this by implementing your own method in your test file.