Error occurs when a desktop flow action fails to get a UI element
This article describes the different causes and solutions for the error messages that may occur when a desktop flow action fails to get a UI element.
Symptoms
The execution of a desktop flow fails with one of the following error messages:
For UI automation actions:
Error 1
Action failed (failed to get window)
where "Action" is the respective Power Automate for desktop action.
Error 2
Action failed (failed to get UI element)
where "Action" is the respective Power Automate for desktop action.
Error 3
UIAutomation.ActionFailedError
where "Action" is the respective Power Automate for desktop action.
For Browser automation actions:
Error 1
Element with selector 'xyz' not found
where "xyz" is the selector that pinpoints the element.
Error 2
WebAutomation.ElementNotFoundError
Cause for the "Action failed (failed to get window)" error
Either the screen (window) isn't available on the machine (it isn't open), or the selector of the screen isn't valid.
Resolution
To solve the issue, you need to:
Ensure the parent screen of the UI element is available on the machine. If not, the error message will indicate "Failed to get window."
Moreover, the "Failed to get window" error may be generated in case the selector of the parent screen is invalid. To fix this issue, see the following instructions.
Cause for the other scenarios
Either the specific UI element isn't available on the screen (window), or its selector isn't valid.
Resolution
To solve the issue, take the following steps:
Ensure the UI element is available on the respective screen or webpage.
Capture the UI element again as a new UI element object and populate the erroneous action with the new UI element.
Navigate to the selector builder and add a new selector using the Selector with recapture option.
Manually edit the selector in the selector builder or its text editor mode.
Check if the selector of the UI element is dynamic. A UI element has a dynamic selector when the selector is slightly different every time the window is launched or the web page loads. To check whether a UI element has a dynamic selector:
- Capture the UI element.
- Restart the window or reload the webpage.
- Capture the exact same UI element.
- Compare the two selectors and observe if there are any differences. You can perform the comparison in Notepad.
- Edit the selector (one of them) manually using the operands or editing the values of the attributes.
Use alternative approaches for interacting with the element on the screen. You can use image automation, mouse and keyboard actions, and optical character recognition (OCR).
If you receive the "Failed to get UI element" or "Failed to get window" error when a UI automation action fails in Microsoft Power Automate, see UI automation action fails with "Failed to get UI element" or "Failed to get window" error.