dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.84k stars 1.67k forks source link

[UITest] AutomationId not being set in Shell Tabbar #19328

Closed bcaceiro closed 6 months ago

bcaceiro commented 7 months ago

Description

With a Shell App, I am writing UITests, with NUnit + Appium ( per documentation), however, using Shell Tabbar I cannot navigate to each tab using AutomationId

Example:

<Shell x:Class="XXX.XXX.XXXl"
       xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       Title="Test"
       Shell.FlyoutBehavior="Disabled">

    <TabBar>
        <Tab Title="Home">
            <Tab.Icon>
                <FontImageSource FontFamily="FARegular" Glyph="{x:Static styles:IconHelper.House}" />
            </Tab.Icon>
            <ShellContent Title="Home"
                          ContentTemplate="{DataTemplate pages:HomePage}"
                          Route="HomePage" />
        </Tab>

        <Tab Title="Orders" AutomationId="OrdersTabBtn">
            <Tab.Icon>
                <FontImageSource FontFamily="FARegular" Glyph="{x:Static styles:IconHelper.CartShopping}" />
            </Tab.Icon>
            <ShellContent Title="Orders"
                          AutomationId="OrdersTabBtn2"
                          ContentTemplate="{DataTemplate pageOrder:MyOrdersPage}"
                          Route="MyOrders" />
        </Tab>

    </TabBar>

</Shell>

It seems that it is setting the Title and not the AutomationId ( however I cannot find the element even by Title)

Steps to Reproduce

  1. New dotnet maui App, with Shell
  2. Set up an AutomationId to a TabBar page
  3. UI Test -> find AutomationId from TabBar and try to click, it cannot find the correct element

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android API 33

Did you find any workaround?

No workaround - I tried finding element by Title and it does not work.

Haven't tried in iOS yet.

Relevant log output

No response

bcaceiro commented 7 months ago

More info: I found this: https://github.com/xamarin/Xamarin.Forms/issues/1529

From Xamarin.Forms days -seems like the same issue?

My question for the Team, in your UI Tests how to you test Shell? ( Tabs, and perhaps Flyouts?)

PureWeen commented 6 months ago

Duplicate of #3996

With Xamarin.UITest we used the Text of the tabs to switch between them. Currently all our shell tests run as on device tests not using appium.

bcaceiro commented 6 months ago

@PureWeen so there is no way atm I can use UItesting with automationids and appium?