locked
Window Searches RRS feed

  • Question

  • I am building a data driven test that opens and closes 2400 programs (this is to verify that upon a new release all programs can be opened and closed before sending out to client). The program reads the program name off the data driven table, then launches and closes the program. In addition, verification is made that the correct program was opened by verifying the text on the title bar to the text on the data driven table that corresponds to that program name.

    The challenge I have is the expected and unexpected popups that may 'popup' that have to be closed if they surface. Right now, I have coded in searches by class name and text on the title bar (I can infer the text name by using the program name), which will hopefully find the popups if they occur. Not all programs have the standard popup title bars, so I have to do additional searches for different scenarios. The additional searches take time, since I have to do the additional searches for all programs since I do not know beforehand if popups will occur, nor do I know if the program with which I am working has a special scenario (unless I hard code, which I do not particularly want to do).

    That said my question is: Is there is a better approach? For example, would it make sense to search the desktop for all open windows and get the title bar text to see if there are any popups? I coded a program that uses "GetForgroundWindow" to get the active window. When I did that, I got the Visual Studio 2010 window. Would it then make sense to walk through all the open windows to see what is there (i.e. popups?).

    I welcome your thoughts. 

    Tuesday, April 27, 2010 12:20 PM

Answers

  • on a side note you can iterate through all the Window elements by

    WinWindow win = new WinWindow();
          UITestControlCollection col = win.FindMatchingControls();
          MessageBox.Show(col.Count.ToString());
    
          foreach (WinWindow wind in col)
          {
            Console.WriteLine(wind.Name);
          }

     Where .Name will give you the title of the window control.

    Thanks

    Siddhartha

    Tuesday, April 27, 2010 6:48 PM
    Moderator

All replies

  • So, is the problem this? - Your main window won't come up unless your pop-up window is dismissed?

    For identifying whether a control is popup or not, ApplicationUnderLaunch itself has a PopUp property. I would use code in the below format

     

    public bool ValidateWindow(string path, string title)

    {

    ApplicationUnderTest aut = ApplicationUnderTest.Launch(path);

    if(aut.IsPopup)

    {

    DismissDialog(aut);

    }

    WinWindow window = new Window();

    window.SearchProperties.Add(Window.PropertyNames.Name, titleExpected);

    return window.Exists;

    }


    Please mark the post as answered if this answers your question. ThejK
    Tuesday, April 27, 2010 1:02 PM
  • You can additionally add the SearchCOnfiguration VisibleOnly for the WinWindow.

    window.SearchConfiguration.Add(SearchConfiguration.VisibleOnly);

    This will make the search a little faster.


    Please mark this post as answer if this answers your question
    Tuesday, April 27, 2010 1:17 PM
    Moderator
  • I was thinking if there was a way to somehow loop through all the windows that are currently open after launching a program. There may be multiple popups, and there could be any number of titles. I may not know the title of the popups, but would only know the title of the main program. Thus, I would want to look at all the open windows, and do the proper evaluation by looking at the text on the title bar. Once I have a match between the text on the title bar and the text from the data driven table, I know that I have found the main prorgam, and all the other windows are either popups or from other applications. 
    Tuesday, April 27, 2010 6:14 PM
  • There is a bool property "WinWindow.Popup". You can narrow down your search further using this.
    Please mark this post as answer if this answers your question
    Tuesday, April 27, 2010 6:41 PM
    Moderator
  • on a side note you can iterate through all the Window elements by

    WinWindow win = new WinWindow();
          UITestControlCollection col = win.FindMatchingControls();
          MessageBox.Show(col.Count.ToString());
    
          foreach (WinWindow wind in col)
          {
            Console.WriteLine(wind.Name);
          }

     Where .Name will give you the title of the window control.

    Thanks

    Siddhartha

    Tuesday, April 27, 2010 6:48 PM
    Moderator
  • Hello,

    Is there any way to dismiss/close popup windows that don't belong to the tested application ?

     

    thanks, ayelet

    Tuesday, June 22, 2010 3:14 PM