I use Windows Automation to test my interface and open and close processes. I want to have a valid WindowHandle, but Process.WaitForInputIdle () does not wait long enough. I have a job, but don't understand why WaitForInputIdle () is not working.
Below is a small snapshot of the code:
Process = new Process
{
StartInfo =
{
WorkingDirectory = directory,
FileName = EXECUTABLE_FILE_NAME
}
};
Process.Start();
int count = 0;
while (Process.MainWindowHandle == IntPtr.Zero && count<100)
{
count++;
Thread.Sleep(100);
}
AppElement = AutomationElement.FromHandle(Process.MainWindowHandle);
source
share