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:
This is a partial solution if we cannot find a solution in WPF (I highly doubt, there is no possibility). Someone suggested I use a MetaBot, which is capable of screening the entire window, and yes, in this way, you're able to identify all controls that are visible (not in all tools, i.e., SAP without SAP scripting enabled, it's impossible).
However, I wouldn't recommend it since this won't solve major issues or bring stability in future changes or drastic ones from the screen or UI.
Also, I can suppose based on my experience that is going to be less efficient since in the "regular process" you are going to access a specific AutomationID of a unique control based on Object Cloning while in the MetaBot, you're going to constantly access the full screen to get all controls and later choose one by one using the logic you created and you will need to repeat the same actions each time for each screen and follow the same pattern for each action. Further, why do I think it's less efficient, you might ask because you're adding complexity to the solution.
If I find a better answer or solution, I'm going to add it as soon as I have it.
P.S.
It doesn't work for A2019. AA removed support for MetaBots and there is no current alternative besides image recognition.
For the time being, this is the only solution since neither Microsoft (they tried to silence me moving my question to the Off-Topic section and didn't reply my comment to move it back to the correct forum) nor AA (I had longs talks with them and they didn't want to take any responsibility or raise the ticket to MS for support) wants to help.
It's important to highlight that it's not necessary a reliable solution since the next version of Automation Anywhere v2019 it's a totally different tool based on different technologies that might not support everything "in the beginning" and could collapse all your robots and could lead to re-write your robots from scratch (I talked about this since they don't have proper migration tools).