Jared Beach
Jared Beach

Reputation: 3133

How to refresh WPF AutomationElement with DataTemplate - Windows UI Automation

I am trying to automate the testing of a WPF application using Windows UI Automation.

The application has a ContentControl with a data template that changes based on user interaction.

On initial load, I am able to get and click a button inside of the content control. This switches the data template (the sub-controls are removed and replaced with other ones).

However, when I look for the new controls in the automation element, they cannot be found.

I am using the wrapper FlaUI, but I've also tried White and they both have the same sort of result.

I am not using caching, but it seems like the window is somehow cached. Is there a way to reload the element or entire window so that I can retrieve the new controls.

Upvotes: 1

Views: 840

Answers (1)

Jared Beach
Jared Beach

Reputation: 3133

Found the solution on FlaUI's FAQ.

When using DevExpress controls, some things (like tab content) are not updated By default, DevExpress controls do not raise automation events, as these events may decrease the application performance. To make sure that the events are raised properly, set the ClearAutomationEventsHelper.IsEnabled static property to false on application startup (needs to be done in the application that is automated with FlaUI):

ClearAutomationEventsHelper.IsEnabled = false;

Upvotes: 2

Related Questions