|
| 1 | +--- |
| 2 | +title: Troubleshoot Incorrect UI Element Clicked or Populated in Desktop Flow |
| 3 | +description: Resolve issues in Power Automate of desktop targeting the wrong UI element during automation. Learn how to ensure accurate clicks and text population. |
| 4 | +ms.reviewer: iomimtso, nimoutzo, v-shaywood |
| 5 | +ms.date: 11/26/2025 |
| 6 | +ms.custom: sap:Desktop flows\UI or browser automation |
| 7 | +--- |
| 8 | +# Wrong UI element is clicked or populated in desktop flow |
| 9 | + |
| 10 | +This article resolves an issue in which Power Automate for desktop interacts with the wrong UI element instead of the element that you captured during flow design. This issue occurs even though the [Test Selector](/power-automate/desktop-flows/test-selectors) tool detects the right element. |
| 11 | + |
| 12 | +## Symptoms |
| 13 | + |
| 14 | +When you run a desktop flow that includes UI automation actions such as [Click UI element in window](/power-automate/desktop-flows/actions-reference/uiautomation#click) or [Populate text field in window](/power-automate/desktop-flows/actions-reference/uiautomation#populatetextfield), the flow interacts with a different UI element than the one that you originally captured. |
| 15 | + |
| 16 | +You might observe the following symptoms: |
| 17 | + |
| 18 | +- The action runs without errors but targets an unexpected element. |
| 19 | +- The wrong element receives the click or text input during runtime. |
| 20 | +- The [Test Selector](/power-automate/desktop-flows/test-selectors) tool successfully identifies the correct element during design time. |
| 21 | + |
| 22 | +## Cause |
| 23 | + |
| 24 | +This issue occurs because the target application handles focus, enable, or disable events in an unexpected way. Some applications dynamically change element focus or states. This functionality can cause UI automation actions to interact with the wrong element. |
| 25 | + |
| 26 | +## Solution |
| 27 | + |
| 28 | +To resolve this issue, use a combination of UI automation and mouse and keyboard actions to ensure proper element targeting. Use one of the following methods based on whether you have to click or populate text. |
| 29 | + |
| 30 | +### Click an element by using hover and mouse click |
| 31 | + |
| 32 | +Instead of using the [Click UI element in window](/power-automate/desktop-flows/actions-reference/uiautomation#click) action, follow these steps: |
| 33 | + |
| 34 | +1. Add a [Hover mouse over UI element in window](/power-automate/desktop-flows/actions-reference/uiautomation#hoveronelement) action, and select the target UI element. |
| 35 | +1. Add a [Send mouse click](/power-automate/desktop-flows/actions-reference/mouseandkeyboard#sendmouseclick) action, placed immediately after the hover action, to click the element. |
| 36 | + |
| 37 | +To prevent focus-related issues, this approach makes sure that the element receives focus through the hover action before the click is sent. |
| 38 | + |
| 39 | +### Populate a text field by using focus and send keys |
| 40 | + |
| 41 | +Instead of using the [Populate text field in window](/power-automate/desktop-flows/actions-reference/uiautomation#populatetextfield) action, follow these steps: |
| 42 | + |
| 43 | +1. Add a [Focus text field in window](/power-automate/desktop-flows/actions-reference/uiautomation#focustextfield) action, and select the target text field. |
| 44 | +1. Add a [Send keys](/power-automate/desktop-flows/actions-reference/mouseandkeyboard#sendkeys) action to input the desired text. |
| 45 | + |
| 46 | +To make sure that text is entered in the intended field, this approach explicitly sets the focus to the correct text field before the keystrokes are sent. |
0 commit comments