WPF Controls are not recognized

robot
studio
uipath

#1

Fellow UiPathers,

I am trying to automate some tools that we use at my company, this tools are developed in WPF and I have noticed that neither the recorders nor UiExplorer can detect them. I tried all options from the UiFrameworks: Default, Active Accessibility and Ui Automation and all them failed to detect any control in a simple code like this one:

<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"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="91,60,0,0" VerticalAlignment="Top" Width="75"/>
        <Label x:Name="label" Content="Label" 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"/>

    </Grid>
</Window>

I always got the following screen:

Does anyone know what should I enable in UiPath? Because in Windows Forms is capable of detecting any control. Thanks for your recommendation and let’s continue building more robots together!


#2

Can you try click image option ?


#3

Despite that image recognition is an option, it’s not what I’d like to do because I could understand this issue if I was programming in Java, Python or any other technology, but not a Microsoft one because even UWP apps like Windows 10 Calendar is recognized by Ui Automation (because I tested it) and WPF is not exactly a very uncommon technology, it has been for a while in the market since 2006; therefore, for sure, I am doing something wrong or I must enable something that I’m not aware of.


#4

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.


#5

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.