Automating App with no main window on start

Feb 22, 2016 at 7:23 PM

I am having problems automating an application which has no main window on startup.
  • The application start with a splash screen.
  • If database is empty, it starts another problem, updater.exe which get latest data from Web.
  • Finally then it starts the program with a main window and a login dialog.
I tried to use some of the code in UIAutomationTests.cs in the sample to start it. I have been succesful starting windows Notepad or Paint. But i'm getting an error with my application. The exact line of crash is:

IOutOfProcessAutomatedApplicationImpl.cs line 224.
this.MainWindow = AutomationElement.FromHandle(Process.MainWindowHandle);

This is in OnActivated(...), The exact error is {"hwnd cannot be IntPtr.Zero or null."}. The main window handle is instanciated, but the window is not there yet. I am guessing that's why it's crashing.

Any way to make this work?

Is there a way to start the application manually and pick it up with TestApi?
Feb 25, 2016 at 2:28 AM
Hello Raphael,
If your hwnd is null, then you need to wait for your window to be fully created before you can proceed with the test.
There are methods on Process that allow you to wait for your process. I suggest using those.