Symptom

A UI automation action fails with one of the following error messages:

  • Failed to get element

  • Failed to get window

  • Element wasn’t found

  • Window wasn’t found

Verifying issue

The first time that the element was captured during authoring of the Desktop flow, PAD was able to interact with the element successfully. 

Cause

Cause #1

Either the window name of the application or the underlying structure of the element has changed. Therefore, the UI selector initially used to locate the element is no longer applicable. 

Cause #2

The application runs with more elevated privileges than Power Automate Desktop.

Resolution

For Cause #1

Edit the UI selector of the element to create a new more robust UI selector, that will be able to locate the element even if the window name or the underlying structure of the element is dynamic. Any parts of the selector that are dynamic, should be removed.


To achieve that, capture again the element after the failure, and compare the new selector with the old one to identify the differences.
Note that the selector of each UI element consists of two (2) parts. The Window selector, and the element's selector within that window.

alternate text


Now identify the element or attribute that has changed in either one of the above. There may be one or more elements/attributes that are different. 

UI selectors can be reviewed and edited through the Selector builder window: 


alternate text


Edit the selector to make sure that it contains only static elements/attributes that are not going to change. 

For example, if the window name has a dynamic part at the end, instead of “Name – Equal to – MyWindowName (2)”, it could be modified to “Name – Starts with - MyWindowName”


In general, the below methods could be followed: 

  • Remove any dynamic values like numbers and modify the relevant Operators accordingly (Starts with, Ends with, Contains etc.)

  • Remove entire elements from the selector path if necessary

Alternative solution

Surface automation can be used as an alternative to automate the application. Refer to the following article for best practices on How to automate with Mouse, Keyboard and OCR.

For Cause #2

Both the application and PAD should run with the same privileges.

Power Automate Desktop does not run elevated by default. Hence, uncheck the "Run this program as an administrator" checkbox in the Compatibility section of the application's Properties window.

Another option would be to set PAD to run as admin as well.

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

What affected your experience?

Thank you for your feedback!

×