Handling playback failures in Coded UI Test due to stale UI controls

This post addresses playback failures in Coded UI Test caused by stale UI controls, specifically when interacting with controls within popup windows like dialog boxes or context menus. It explains that the error 'FailedToPerformActionOnBlockedControlException' often stems from a stale accessible object persisting after an earlier instance of the same window was not disposed of properly. The post provides three workarounds: 1. Using the `VisibleOnly` search configuration for the target control and its ancestors. 2. Combining `VisibleOnly` with `AlwaysSearch` (with caution due to performance impact). 3. Using the `OrderOfInvocation` property for the top-level window to disambiguate duplicate windows. It also suggests using `DrawHighlight()` for visual verification and provides a method to collect all matching windows to verify the desktop session state.
More from the Coded UI Test Deprecation and Alternatives trail
- Changes to Coded UI Test in Visual Studio 2019
- Troubleshooting launch issues with xaml based apps using Coded UI Test
- Coded UI Test Extensibility V2
- Coded UI testing support for Silverlight using Visual Studio 2013
- Test controllers are not visible or marked offline in MTM when multiple versions of MTM are installed