I am facing a recurring issue while automating a desktop application using Power Automate Desktop.
Scenario:
- I have created a flow that interacts with a Windows desktop application.
- Whenever a new version of the application is released, I update the version number in the Windows element selector, and the script works fine initially.
- However, after some time (even without major changes), the script suddenly fails from the very first step.
Problem:
- The flow fails with a generic error stating that it cannot locate the element.
- Even if there is only a minor UI change, the entire flow breaks.
- When I try to “relocate” an element, it only fixes that specific step.
- For the next step, the same issue occurs again.
- Eventually, I end up having to re-capture/relocate almost every element, which is equivalent to recreating the whole flow.
Error Details:
Correlation Id: 1abf6b8b-1bea-46f9-9908-30d5645856bb
Exception of type 'Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Exceptions.WindowNotFoundException' was thrown.: Microsoft.Flow.RPA.Desktop.Modules.SDK.Extended.Exceptions.InternalActionException: Click failed (failed to get window) ---> Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Exceptions.WindowNotFoundException: Exception of type 'Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Exceptions.WindowNotFoundException' was thrown.
at Microsoft.Flow.RPA.Desktop.UIAutomation.Core.Abstractions.ServiceRouter1.Invoke(MethodInfo targetMethod, Object[] args)
at generatedProxy_2.ClickElementInWindow(UIRuntimeElement, Int32, Int32, MouseClickTypeEnum, RectangleEdgePointEnum)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithManyArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--- End of remote exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Proxy.RemoteAutomationRuntimeProxy.Invoke(MethodInfo targetMethod, Object[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Reflection.DispatchProxyGenerator.Invoke(Object[] args)
at generatedProxy_2.ClickElementInWindow(UIRuntimeElement , Int32 , Int32 , MouseClickTypeEnum , RectangleEdgePointEnum )
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Actions.ClickElementInWindow.<Execute>b__26_1(IAutomationRuntimeProxy r, UIRuntimeElement e)
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.UIAutomationActionBase.PerformAutomation(Action2 action, UIControl control, Boolean logAction)
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Actions.ClickElementInWindow.Execute(ActionContext context)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Actions.ClickElementInWindow.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary2 inputArguments, Dictionary2 outputArguments)
Questions:
- Is there a more stable way to define selectors so that flows don’t break frequently?
- How can I avoid re-capturing all elements after each version/UI change?
- Are there best practices to make selectors more resilient?
Additional Context:
- This issue has occurred multiple times (4–5 times so far).
Any guidance or best practices would be really helpful.
Thanks in advance!