question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting TimeoutException when calling GetMainWindow

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Roemercommented, Feb 13, 2020

You can use FlaUIs Retry for that. There is an option to ignore exceptions and just retry again in case of an exception. So it would look something like:

var retryResult = Retry.WhileNull(() => automation.FromHandle(mainWindowHandle).AsWindow(), timeout:TimeSpan.FromMinutes(1), ignoreException: true);
window = retryResult.Result;
1reaction
abhijeet-vidhate-spidercommented, Jun 20, 2020

I ran into this issue. Roemer’s suggestion didn’t work as it is for me. I had to change it to

var retryResult = Retry.WhileNull(() => _app.MainWindowHandle != IntPtr.Zero ? automation.FromHandle(_app.MainWindowHandle).AsWindow() : null, timeout: TimeSpan.FromSeconds(Settings.MaxLaunchDelay), ignoreException: true);

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:

Thread.Sleep(TimeSpan.FromSeconds(Settings.MaxLaunchDelay));
_mainWindow = _app.GetMainWindow(automation, null);

and FindFirstDescendant works after that.

Am I missing something here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting TimeoutException when calling GetMainWindow
Hi,. When trying to run automation tests on a virtual server I am getting the following exception: System.TimeoutException: UIA Timeout ...
Read more >
Timeout Exception during call from wpf client to server in ...
1 · In non working does the button click work? · @jdweng it gets there, exception thrown on channel. · Add a 10...
Read more >
TimeoutException Class (System)
Initializes a new instance of the TimeoutException class with the specified error message and inner exception. Properties. Data. Gets a collection of key/value ......
Read more >
Help needed:Timeout Exception when calling web service ...
I am calling synchronous web service using web service consumer and passing the payload coming from file with header information. I am getting...
Read more >
Error 'Org.openqa.selenium.TimeoutException: Timed out ...
Since webDriver has a “pageloadstrategy” set to normal. This means that whenever calling a web page, the web driver will run the JS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found