Forum Xamarin.Forms

Hamburger menu AutomationId for UI Testing.

toyinstoyins USMember ✭✭✭

I'm trying to run a UI Test on a page (About.xaml).
Below are the steps to get to the page when the application loads.
1. Launch the Login Screen
2. User enters username
3. User enters password
4. User clicks on the Login Button
5. User lands on the Home Page in an AppShell.
6. User clicks on the Hamburger menu
7. User clicks on the About Menu in the Flyout Menu Items.

My question is, how do I set the Automation Id for the Hamburger Menu (Flyout Menu) of the AppShell?

Here's the UI Test Case.

            [Test]
    public async Task AboutPage_UITest()
    {

        //Arange
        app.EnterText("UsernameEntryId", "user1");
        app.EnterText("PasswordEntryId", "[email protected]");


        //Act
        app.DismissKeyboard();
        app.Tap(x => x.Marked("LoginButtonId"));

        app.Tap(x => x.Marked("AppShellId"));
        //app.Tap(c => c.Class("OverflowMenuButton"));  I tried this as well but no luck.
        await Task.Delay(30000);


        app.Tap(x => x.Marked("AboutId"));

        //Assert

        var appResult = app.Query("EmailId").First(result => result.Text == "[email protected]");
        Assert.IsTrue(appResult != null, "Label is not displaying the right result!");

        app.Screenshot("About Page");
    }

In the AppShell.xaml, here's the top section.

            <Shell xmlns="http://xamarin.com/schemas/2014/forms"
                     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                     FlyoutHeaderBehavior="CollapseOnScroll"
                     Shell.ItemTemplate="{StaticResource FlyoutTemplate}"
                     Shell.MenuItemTemplate="{StaticResource FlyoutTemplate}"
                     FlyoutBackgroundColor="WhiteSmoke" 
                     Navigating="OnNavigating" 
                     Navigated="OnNavigated"
                     AutomationId="AppShellId"
                     x:Class="DemoApp.AppShell">
Sign In or Register to comment.