Xamarin.Forms and Xamarin.UITest: how to manage ScrollUp? RRS feed

  • Question

  • User167645 posted

    I would like to implement some UI Tests in a Xamarin.Forms app, by using Xamarin.UITest.

    On my main page, I have a ScrollView that contains some informations in Labels, like a phone number, an address, an email, ...

    The XAML looks like this:

    <ScrollView x:Name="parallaxScrollView"
        <!-- ... -->
        <!-- Phone -->
        <yummy:PancakeView Style="{StaticResource YummyFrame}"
            <Grid RowSpacing="0">
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                <Label Grid.Row="0"
                        Style="{StaticResource HomePageHeaderLabelStyle}"
                        Text="{x:Static strings:Strings.HomePagePhoneNumberHeader}">
                <Label Grid.Row="1"
                        Style="{StaticResource HomePageLabelStyle}"
                        Text="{Binding PhoneNumber}" />
        <!-- ... -->

    I would like to check that all expected informations are well displayed.

    The 2 first items are always visible, so I only have to do this in my UI test:

    AppResult[] results = app.WaitForElement(t => t.Marked("Phone number"));

    But for the following items, I have to scroll up before the other informations are visible. So I've tried to to use the ScrollUp() based on a Label or on the ScrollView, but nothing happens:

    app.ScrollUp(c => c.Marked("ContentScrollView"));
    AppResult[] results = app.WaitForElement(t => t.Marked("Email"));
    //AppResult[] results = app.WaitForElement(t => t.Marked("Phone number"));

    I also tried to use the ScrollUpTo() method but I get the same result.

    I didn't found a sample in a Xamarin.Forms project, so I'm not sure to well understand this... Could you help me?

    Friday, December 11, 2020 3:13 PM

All replies

  • User167645 posted

    I've managed to achieve this by applying the scroll using ScrollDown. I don't understand why, as the gesture is well a scroll from bottom to top...

    Saturday, December 12, 2020 10:29 AM