Appium Can't See Automation ID

I am new to appium and have been tasked with automating some tests of our mobile app written in Xamarin. I have been struggling for a few days trying to understand why automation id’s I am setting in our code behind are not being surfaced to appium. I am able to assign automationid to standard xamarin controls and the value appears in the appium inspector. When I attempt to do the same to a custom control I can see the value is set in visual studio but it doesn’t appear in the appium inspector. As an example there is a custom control “lbl” that extends Xamarin.Forms.Label:

public class Lbl : Xamarin.Forms.Label
public Lbl(string text, XColor txtclr, UI.FontSizes fsz = UI.FontSizes.Default) : base()
if (UI.FontSizes.Default == fsz) {
fsz = UI.FontSize.Std;

            Text = text;
            TextColor = txtclr;
            FontSize = (double)fsz;
            BackgroundColor = Color.Transparent;
            LineBreakMode = LineBreakMode.NoWrap;
            Margin = 0;
            Padding = 0;
            HorizontalTextAlignment = TextAlignment.Start;
            VerticalTextAlignment = TextAlignment.Center;
            HorizontalOptions = LayoutOptions.Start;
            VerticalOptions = LayoutOptions.CenterAndExpand;


Then where I see an instance of the lbl class created, I am attempting to assign the automation
id in the same way I did for content view:
thelabel.AutomationId = “some-specific-automation-id”;

I have tried various things I found online including setting AutomationProperties.IsInAccessibilityTree to true for the control along with setting the AutomationProperties.NameProperty to a value but this hasn’t changed the outcome.

I am entirely confused and have spent a good amount of time googling this to no avail. The developer who is writing the app see’s no reason this shouldn’t work, but neither of us have past experience with xamarin or appium so it is likely we are both missing something obvious.

Can anyone tell what I am missing? Is there some documentation out there that lays out the process of implementing automation ids on custom xamarin controls?

Full disclosure: I don’t work with Xamarin apps.

I did a quick web search and came up with this document. According to it, you might try something like AutomationProperties.Name:

Hope it helps and wish I had more advice. Good luck.

Thanks Wreed - I appreciate your response.

I tried that to start but intellisense corrected it to NameProperty because I am in C# not XAML. For a day or so I have been messing with those examples and some others I found but for some reason the they just weren’t working for me. On a whim I decided to try moving the
AutomationProperties.SetIsInAccessibleTree(thelabel, true); into the class itself and that worked :woman_shrugging:

I think this has to do with our setup - the dev writing the app has foregone XAML and gone with C# essentially everywhere. It seems to me that if we were using XAML in the traditional way this would have been easier, but at least it is working.

I have seen this issue as well. It works for iOS but not for Android. In my work with it. Labels can have it but I think in xamarin 4.8 they have ended any binding automations so you want to stay away from that.