rid00z / FreshMvvm

FreshMvvm is a super light Mvvm Framework designed specifically for Xamarin.Forms. It's designed to be Easy, Simple and Flexible.
Apache License 2.0
596 stars 172 forks source link

Support Needed for UITests and AutomationId on Tabs #242

Open SunnyMukherjee opened 6 years ago

SunnyMukherjee commented 6 years ago

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

drjaydenm commented 5 years ago

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.

bsloehr commented 5 years ago

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