Getting TimeoutException when calling GetMainWindow
See original GitHub issueHi,
When trying to run automation tests on a virtual server I am getting the following exception:
System.TimeoutException: UIA Timeout —> System.Runtime.InteropServices.COMException: Operation timed out. (Exception from HRESULT: 0x80131505)
Stack Trace:
at Interop.UIAutomationClient.CUIAutomation8Class.ElementFromHandle(IntPtr hwnd)
at FlaUI.UIA3.UIA3Automation.<>c__DisplayClass27_0.<FromHandle>b__0()
at FlaUI.Core.Tools.Com.Call[T](Func1 nativeAction) --- End of inner exception stack trace --- at FlaUI.Core.Tools.Com.Call[T](Func1 nativeAction)
at FlaUI.UIA3.UIA3Automation.FromHandle(IntPtr hwnd)
Is there anyway to change the timeout? I have tried setting ConnectionTimeout and TransactionTimeout in the following way however it does not seem to make a difference
automation.ConnectionTimeout = new TimeSpan(0, 5, 0); automation.TransactionTimeout = new TimeSpan(0, 5, 0);
Everything works correctly on a physical machine so it could be because the VM is a little slow.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (5 by maintainers)
Top Related StackOverflow Question
You can use FlaUIs
Retryfor that. There is an option to ignore exceptions and just retry again in case of an exception. So it would look something like:I ran into this issue. Roemer’s suggestion didn’t work as it is for me. I had to change it to
That way, i could get the main window object. But even after that, very first FindFirstDescendant call fails to give me the control I am looking for. Just as an alternative, I tried following code:
and FindFirstDescendant works after that.
Am I missing something here?