4

I have a suite of UITest for our Xamarin Forms project. All of the AutomationId's are present in the XAML file and work fine on the iOS project. However when running the tests on Android the AutomationId is not there which is causing my tests to fail.

I've doubled checked using REPL and tree to inspect each view for it's Id's

Mike
  • 41
  • 2

3 Answers3

1

Are you initializing the AutomationId's in the OnCreate of the MainActivity in the Android native project?

After the Xamarin.Forms.Forms.Init (this, bundle); :

Xamarin.Forms.Forms.ViewInitialized += (object sender, Xamarin.Forms.ViewInitializedEventArgs e) => {
   if (!string.IsNullOrWhiteSpace (e.View.AutomationId)) {
      e.NativeView.ContentDescription = e.View.AutomationId;
   }
};
SushiHangover
  • 73,120
  • 10
  • 106
  • 165
1

In android app build using Xamarin Forms, the automation id is converted to cont-desc. You can use cont-desc for your test.

Suban Dhyako
  • 2,436
  • 4
  • 16
  • 38
-1

There is no automationId itself visible in REPL, but only label or id with the value equal to that set on the automationId, so you should just use Marked passing in the value.