I am building a new bot in Automation Anywhere 11 and I have found recently a tricky situation when I'm trying to automate the Windows Ribbon.
If I have only one tab everything works as expected and I can identify all buttons inside, but if I have multiple tabs only the last tab elements are visible to the Object Cloning option, I have added unique Names, AutomationIDs, etc. And nothing has worked. This is a preview of the issue:
This is my example XAML code:
<UserControl x:Class="Example.RibbonMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:my="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon">
<my:Ribbon x:Name="R1" AutomationProperties.AutomationId="R1ID">
<my:RibbonTab Header="Tab 1" x:Name="Tab1" AutomationProperties.AutomationId="Tab1ID">
<my:RibbonGroup x:Name="GB1" AutomationProperties.AutomationId="RG1ID">
<my:RibbonButton Label="Button 1" x:Name="RB1" AutomationProperties.AutomationId="RB1ID" />
</my:RibbonGroup>
</my:RibbonTab>
<my:RibbonTab Header="Tab 2" x:Name="Tab2" AutomationProperties.AutomationId="Tab2ID">
<my:RibbonGroup x:Name="RG2" AutomationProperties.AutomationId="RG2ID">
<my:RibbonButton Label="Button 2" x:Name="RB2" AutomationProperties.AutomationId="RB2ID" />
<my:RibbonButton Label="Button 3" x:Name="RB3" AutomationProperties.AutomationId="RB3ID" />
</my:RibbonGroup>
</my:RibbonTab>
</my:Ribbon>
</UserControl>
Also, I have read multiple options:
XAML - Binding row and column index of cell to automation ID
Unable to generate Automation ID for WPF Controls, to be used by coded UI for automation testing
But nothing that I tried so far was worked until recently, I identified that the issue is connected to the last tab. Also, as I said in the comments section, I tried the Legacy Option and Manage Windows Controls too. Here are some previews:
Legacy Option Enabled:
Manage Windows Controls:
Furthermore, another ribboned app like Paint where the buttons are recognized:
Also, I have tested another Microsoft tool: AccExplorer32.exe, which shows exactly the same behavior, proving that this is not a limitation of AA or UiPath, but something from the coding perspective, here you have a preview:
Does anyone have an idea how to fix it? Or has experienced something similar? Thanks for your help.
P.S.
I'd not want an answer about Image Recognition or MetaBots (partial solution and quite good in the case of AA) as options since this is a programming issue and I'm interested to solve it.
I identified a second problem regarding the TabControl. If for any reason when you have only one TabItem active and you decide to hide the tab name for aesthetic reasons, my advice is to enable it for robots since if you hide it then the robot cannot find any elements inside and you might need a MetaBot, which wouldn't be as reliable as you want to.
Not working:
The tabs don't work even with MetaBots:
Working:
- Also, I was able to find an example with Window Forms, Windows SDK and the regular ribbon from MS where it works as expected since the first time without any specific adjustment.