Problem with modal window

Mar 5, 2008 at 8:07 PM
Hi,
I am in the process of evaluating different frameworks for UI Automation, and this one really shows some promise. Love the syntax, and it fits our plans just perfectly.
My company's product is a patient journal / patient administration / booking application used at hospitals, and for a test I tried to use the framework against that app. The app itself is mostly developed in Delphi, but UI Automation against it seems to be working just fine. But I did come a across a major stumbling block:
When the app launches, it launches the main MDI form, and in the load event for that window, it opens a modal window, prompting the user for login information.
I can get a reference to the main MDI form using Application.GetWindow, but I am somehow not able to access the Modal Dialog. It doesn't enumerate under the Application.GetWindows method, and using the ModalWindow method on the main MDI form doesn't find it either.
What's really strange is that UI Spy is reporting the login form as another top-level window, I was somehow expecting it to be a child window of the MDI Form. Could that be the issue?

Any pointers appreciated!

Thanks,
Erling
Coordinator
Mar 6, 2008 at 4:55 AM
Application.GetWindows(), gets all the windows for specific process with which it was initialized. Can you please check if your login window belongs to some other process?
Mar 6, 2008 at 10:24 AM
UI Spy reports same process for both windows. Here's the snip from UI Spy:
Modal Form:
Identification
ClassName: "TInnlogging"
ControlType: "ControlType.Pane"
Culture: "(null)"
AutomationId: ""
LocalizedControlType: "rute"
Name: "DIPS Testsykehuset DIPS"
ProcessId: "5604 (dw2)"
RuntimeId: "42 134452"
IsPassword: "False"
IsControlElement: "True"
IsContentElement: "True"

MDI Form:
Identification
ClassName: "THoved"
ControlType: "ControlType.Window"
Culture: "(null)"
AutomationId: ""
LocalizedControlType: "vindu"
Name: "FeFDips"
ProcessId: "5604 (dw2)"
RuntimeId: "42 134468"
IsPassword: "False"
IsControlElement: "True"
IsContentElement: "True"
Mar 6, 2008 at 10:28 AM
Using a hack I found here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=697776&SiteID=1&pageid=0 ,I am able to retreive a AutomationElement for the modal Dialog. How do get a Window from an AutomationElement?
Coordinator
Mar 22, 2008 at 7:06 PM
Quite likely you would have found the solution yourself. (for some reason I didnt get the notification in RSS feed).
The API is not meant to be used like this but in this case there is no other option till I fix this somehow. (Reason of problem is because the ModalWindow of yours is showing up as Pane and not window).
This code would be useful for you:
WindowsFramework windowsFramework = new WindowsFramework(element.Current.FrameworkId);
if (windowsFramework.WinForm) return new WinFormWindow(element, option, windowSession);
else if (windowsFramework.WPF) return new WPFWindow(element, WindowFactory.Desktop, option, windowSession);
else if (windowsFramework.Win32) return new Win32Window(element, WindowFactory.Desktop, option, windowSession);
Use NullWindowSession for your purpose. This also means you cannot take benefit of Speed up performance by Position based search.