FreshMvvm icon indicating copy to clipboard operation
FreshMvvm copied to clipboard

Support Needed for UITests and AutomationId on Tabs

Open SunnyMukherjee opened this issue 6 years ago • 2 comments

Hello,

I am writing UITests using App Center for Android and iOS. I am using FreshMVVM and the FreshTabbedNavigationContainer as the startup page and adding tabs to it. I can set the AutomationId manually on controls within each ContentPage. That is working fine.

But I was not able to find a way to set the AutomationId of each tab in the FreshTabbedNavigationContainer. I need to be able to set the AutomationId so the UITest has visibility of the controls during testing so the test can tap on the Tab and proceed with the UI testing within the ContentPage inside the tab. I tried setting the AutomationId on the ContentPage itself, but it did not work during the UITest.

Does anyone know of a short-term solution? Or does this need to be a feature request?

Thanks, Sunny

SunnyMukherjee avatar Oct 16 '18 16:10 SunnyMukherjee

We were just looking at how to accomplish this and found that FreshMvvm already returns the Page object when calling the AddTab<> method. You can assign to the AutomationId property on that page and it will be used for the tab bar button on iOS.

var tabbedNavigation = new FreshTabbedNavigationContainer(); tabbedNavigation.AddTab<HomePageModel>("Home", "home.png").AutomationId = "HomeTab";

For Android it was a little bit trickier, but we just created a custom renderer to do this for us as we were using the app-compat tab bar. This isn't the cleanest but it works for now - not sure if FreshMvvm can make Android support any easier seeing as the default Xamarin TabbedPage doesn't setup the AutomationId either.

drjaydenm avatar Sep 24 '19 05:09 drjaydenm

@drjaydenm Can you elaborate a bit on how you got the custom renderer to be recognized by the FreshTabbedNavigationContainer?

bsloehr avatar Sep 26 '19 14:09 bsloehr