WPF Controls are not recognized

I found my own solution and I hope it’s going to help more people. What happens if you are developing with WPF is that you should enable some properties called AutomationProperties and add the Automation IDs to the controls that you want to automate making them discoverable by the tools like in this example:

New code with automation properties:

<Window x:Class="UiPathExample.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:local="clr-namespace:UiPathExample"
		mc:Ignorable="d"
		AutomationProperties.AutomationId="Window1"
		Title="MainWindow" Height="350" Width="525">
	<Grid AutomationProperties.AutomationId="Grid1">
		<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="91,60,0,0" AutomationProperties.AutomationId="btnButton1" VerticalAlignment="Top" Width="75"/>
		<Label x:Name="label" Content="Label" AutomationProperties.AutomationId="lbl1" HorizontalAlignment="Left" Margin="82,121,0,0" VerticalAlignment="Top"/>
		<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" Margin="300,135,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120" AutomationProperties.AutomationId="txtAutomationEx"/>
	</Grid>
</Window>

New result from Ui Explorer:

P.S.:

Personally, I consider this advice should be added somewhere in the documentation or any training of UiPath since many people who works for companies or build their own tools in WPF could experience the same issue that I faced for months because I tried with Automation Anywhere and UiPath and I got the same issue because the lack of these properties.

P.S.
You cannot use it while debugging, you must run the EXE.

2 Likes