This project is read-only.

Using Application.GetWindow Problem

Jan 5, 2009 at 10:07 PM

Being a newbie to the White API, I am attempting to obtain the window using the application.GetWindow function.   Using UISpy, I can see the parent child tree structure relationship in the Control View.  This is a WPF application and I wanted to make sure that I correctly understand the UISpy properties and their UI element usage with the White API.   My problem is that the parent window (Main Window) will display a non-modal child window after user selects a menu option.   At this point, I need to obtain a reference to the child window but for some reason using the Application.GetWindow function fails.   What interesting is that the exception message thrown shows 

Name: WindowSettingsGeneral,  Bounds: 358,14,448,483 ProcessId: 1932, Modal: False

which is the window I am attempting to reference.   Not sure what I am doing wrong here.  Any help is greatly appreciated.

Unit Test Application




Wrapper Function


private Window currentWindow;




public WhiteAPIWrapper Window (string title)
currentWindow = Application.GetWindow (title,
Assert (currentWindow !=
null, "Could not find the '{0}' window by Title.", title);
return this;





WindowSettingsGeneral Window UISpy Values



ControlType: "ControlType.Window"
Culture: "(null)"
AutomationId: "Window"
LocalizedControlType: "window"
Name: "WindowSettingsGeneral"
ProcessId: "920 (onexcui)"
RuntimeId: "42 4524318"
IsPassword: "False"
IsControlElement: "True"
IsContentElement: "True"




"(358, 14, 448, 483)"
ClickablePoint: "582,255"
IsOffscreen: "False"


Pattern Availability


IsExpandCollapsePatternAvailable: "False"
IsGridItemPatternAvailable: "False"
IsGridPatternAvailable: "False"
IsInvokePatternAvailable: "False"
IsMultipleViewPatternAvailable: "False"
IsRangeValuePatternAvailable: "False"
IsSelectionItemPatternAvailable: "False"
IsSelectionPatternAvailable: "False"
IsScrollPatternAvailable: "False"
IsScrollItemPatternAvailable: "False"
IsTablePatternAvailable: "False"
IsTableItemPatternAvailable: "False"
IsTextPatternAvailable: "False"
IsTogglePatternAvailable: "False"
IsTransformPatternAvailable: "False"
IsValuePatternAvailable: "False"
IsWindowPatternAvailable: "True"




ItemType: ""
Orientation: "None"
FrameworkId: "WPF"
IsRequiredForForm: "False"
ItemStatus: ""




CanMinimize: "False"
IsModal: "False"
WindowVisualState: "Normal"
WindowInteractionState: "ReadyForUserInteraction"
IsTopmost: "False"

Exception Message

Core.UIItems.UIActionException : Couldn't find window with title WindowSettingsGeneral in process 1932, after waiting for 5000 ms
Name: Main Window,  Bounds: 382,139,400,233 ProcessId: 1932, Modal: False
  Name: WindowSettingsGeneral,  Bounds: 358,14,448,483 ProcessId: 1932, Modal: False
Name: Gallio Icarus 3.0.4 build 485,  Bounds: 13,22,1011,734 ProcessId: 928, Modal: False


Jan 6, 2009 at 7:09 PM
Worked around this issue by referencing the child window instance by index by calling Application.GetWindows()[1]; instead. 
Mar 18, 2009 at 10:49 PM
Have similar problem. Are there any suggestions here except such workaround?
Mar 25, 2009 at 2:41 PM
you need to get hold of the parent window first and then get the modal window.
cannot get the modal window directly from application