Xamarin.forms: XAML AutomationID ignored by REPL tool and other queries on *Cell components

Created on 14 Dec 2018  路  11Comments  路  Source: xamarin/Xamarin.Forms

Description

@PureWeen notes:
This is also broken with ImageCell and I'm guessing it is broken with the other Cell's as well so when this is resolved make sure to test all the *Cell components. If you look at Issue4597 you'll see the complexity required to test the ImageCell. Once this is fixed please cleanup Issue4597

I'm using Forms app.
In TableView, EntryCell's AutomationId in XAML pages is being ignored, as a result tests are not being able to use AutomationID with XAML pages.

XAML for the settings page:

<TableView Intent="Settings">
        <TableRoot>
            <TableSection Title="First Section">
                <TextCell Text="TextCell" Detail="TextCell Detail" />
                <EntryCell Label="Entry Label" Text="EntryCell Text" AutomationId="ENTRY_CELL_TEXT_1" />
                <SwitchCell Text="SwitchCell Text" />
                <ImageCell Text="ImageCell Text" Detail="ImageCell Detail" ImageSource="XamarinLogo.png" />
            </TableSection>
            <TableSection Title="Second Section">
                <TextCell Text="TextCell" Detail="TextCell Detail" />
                <EntryCell Label="Entry Label" Text="EntryCell Text" AutomationId="ENTRY_CELL_TEXT_2"/>
                <SwitchCell Text="SwitchCell Text" />
                <ImageCell Text="ImageCell Text" Detail="ImageCell Detail" ImageSource="XamarinLogo.png" />
            </TableSection>
        </TableRoot>
    </TableView>

However, tests are not being able to use AutomationIDs defined in the xaml page, Repl tree command fails to display EntryCell's AutomationId

[UITableViewSectionElement] id: "First Section"
[UIAccessibilityElementMockView] label: "First Section"
[UITableViewCellAccessibilityElement]
[UITableTextAccessibilityElement] label: "TextCell, TextCell Detail"
[UITableViewCellAccessibilityElement]
[UITableTextAccessibilityElement] label: "Entry Label"
[UIAccessibilityElementMockView] text: "EntryCell Text"
[UIAccessibilityTextFieldElement] text: "EntryCell Text"
[UITableViewCellAccessibilityElement] text: "0"
[UITableTextAccessibilityElement] label: "SwitchCell Text", text: "0"
[UIAccessibilityElementMockView] label: "SwitchCell Text", text: "0"
[UITableViewCellAccessibilityElement]
[UITableTextAccessibilityElement] label: "ImageCell Text, ImageCell Detail"
[UITableViewSectionElement] id: "Second Section"
[UIAccessibilityElementMockView] label: "Second Section"
[UITableViewCellAccessibilityElement]
[UITableTextAccessibilityElement] label: "TextCell, TextCell Detail"
[UITableViewCellAccessibilityElement]
[UITableTextAccessibilityElement] label: "Entry Label"
[UIAccessibilityElementMockView] text: "EntryCell Text"
[UIAccessibilityTextFieldElement] text: "EntryCell Text"
[UITableViewCellAccessibilityElement] text: "0"
[UITableTextAccessibilityElement] label: "SwitchCell Text", text: "0"
[UIAccessibilityElementMockView] label: "SwitchCell Text", text: "0"
[UITableViewCellAccessibilityElement]
[UITableTextAccessibilityElement] label: "ImageCell Text, ImageCell Detail"
[UITableViewCellAccessibilityElement]
[UIAccessibilityElementMockView] label: "Tap this cell."

Steps to Reproduce

  1. Set automation id of an EntryCell.Label in XAML
  2. Create a simple Xamarin.UITests
  3. Start REPL; run the tree command

Expected Behavior

Automation id of EntryCell.Label should be detected

Actual Behavior

AutomationID is ignored by REPL

Basic Information

  • Version with issue: Xamarin.Forms version 3.4.0.1008975
  • Last known good version: I'm not sure about this.
  • IDE: Visual Studio Community 2017 for Mac
    Version 7.6.2 (build 33)
  • Platform Target Frameworks:

    • iOS
  • Nuget Packages:
    Xamarin.Forms version 3.4.0.1008975
    Xamarin.TestCloud.Agent version 0.21.7
    Xamarin UITest version 2.2.7
    NUnit version 2.6.4

-Affected Devices:
I can reproduce this issue on all the iOS 12 simulators (I don't have any iOS physical devices).

Screenshots

screen shot 2018-12-13 at 3 04 40 pm
screen shot 2018-12-13 at 3 18 49 pm

Reproduction Link

I can reproduce the issue using this sample:

https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/TableView

a11y 馃攳 uitest 4 high impact Android UWP iOS 馃崕 bug up-for-grabs

Most helpful comment

Any updates on this issue?

All 11 comments

I'm following this issue as well for updates or if any other info is needed.

Has there been any progress on this issue? I'm experiencing issues with the tap commands on iOS simulators. I can't target specific UI elements without AutomationIds set in XAML

Is anybody looking at this? This is stopping us doing any UI Testing.

Has there been any progress on this issue?

Any updates on this issue?

This is affecting me too.

I tried the following and I see the automation Id appear in the REPL tool. However, it cannot tap on the toggle because the automation Id is being set on the whole row and not the toggle switch.

I created a class CustomSwitchCell that inherits the custom control from the default Xamarin Forms SwitchCell.
``` C#
public class CustomSwitchCell : SwitchCell
{
public static readonly BindableProperty AutomationIdBindableProperty = BindableProperty.Create(
propertyName: "AutomationIdBindable",
returnType: typeof(string),
declaringType: typeof(SwitchCell),
defaultValue: null);

    public string AutomationIdBindable
    {
        get
        {
            return GetValue(AutomationIdBindableProperty) as string;
        }
        set
        {
            SetValue(AutomationIdBindableProperty, value);
        }
    }
}
Then, I created a Custom Renderer in my iOS project that looks like the following:

``` C#
[assembly: ExportRenderer(typeof(CustomSwitchCell), typeof(YourProject.LocationOfFile.CustomSwitchCellRenderer))]
namespace YourProject.LocationOfFile
{
    public class CustomSwitchCellRenderer : SwitchCellRenderer
    {
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            var cell = base.GetCell(item, reusableCell, tv);

            var customSwitchCell = item as CustomSwitchCell;
            if (customSwitchCell != null && customSwitchCell.AutomationIdBindable != null)
            {
                cell.AccessibilityIdentifier = customSwitchCell.AutomationIdBindable;
            }

            return cell;
        }
    }
}

@PureWeen how come there hasn't been anymore progress on this in over a year?

We rebuilt using the latest Xamarin (4.4) and also have this issue. What's very strange is back when we started to look at automation we had built with 3.4 and the automation was working.

We rebuilt with 3.4 and a few updates to our code and it STOPPED working. What we've noticed is that if you assign the automation ID via code - that does show up but any automation ID assigned via the xaml does not.

Any news on this bug?
I'm having a similar issue but in a CollectionView ONLY ON ANDROID.
I have a ContentView with a Grid, and inside that grid, there is a CollectionView. AutomationID for CollectionView is ignored, if on top of it, I add a StackLayout with an AutomationID, I can see it, but I cannot see the AutomationID for the CollectionView.

i.e:

<StackLayout AutomationId="StackOnTopOfCollectionView" >
                    <CollectionView Grid.Row="0" x:Name="ActivityFeedView" AutomationID="ActivityFeed" Scrolled="ActivityFeedView_Scrolled" ItemsSource="{Binding Items}" Style="{StaticResource CommentsListListView}" IsVisible="{Binding Items, Converter={StaticResource HasItemsConverter}}">
                        <CollectionView.Effects>
                            <Local:CollectionView_AlwaysBounceVertical_Effect />
                            <Local:CollectionView_NoScrollIndicators_Effect />
                        </CollectionView.Effects>
                        <CollectionView.ItemsLayout>
                            <LinearItemsLayout Orientation="Vertical" ItemSpacing="10"/>
                        </CollectionView.ItemsLayout>
                        <CollectionView.ItemTemplate>
                            <!-- Activity Feeds List -->
                            <DataTemplate>
                                <ContentView Style="{StaticResource CommentsViewCell}" AutomationId="{x:Static Automation:TestIdentifier.PUNCHITEMEDITPAGE_COMMENTS_LIST_CELL}">
                                    <Local:CommentsCell OpenMenuCommand="{Binding Source={x:Reference PunchItemCommentsList}, Path=BindingContext.OpenMenuForCommentCommand}"
                                                        OnShowFile="CommentCell_ShowFile" OnShowDrawing="CommentCell_ShowDrawing" /> 
                                </ContentView>
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>
                </StackLayout>

In this case, StackOnTopOfCollectionView is visible with REPL but ActivityFeed is not.

@samhouts or @PureWeen? Feels like this just keeps getting moved on and not done? Can we commit to doing this ASAP please. V5 feels far too far away,

Was this page helpful?
0 / 5 - 0 ratings