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:
Class:
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?