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
22.04k stars 1.73k forks source link

On Android, a `Picker` is replaced by views without id when opening it #16284

Open hansmbakker opened 1 year ago

hansmbakker commented 1 year ago

Description

On Android, the Picker control is represented by an EditText view when closed. When opened, it is replaced by a group of views that do not have an id or semantic properties. This makes it really difficult to use with UI tests.

Steps to Reproduce

  1. Create a File > New .NET MAUI App
  2. Add a Picker like so:
    <Picker Title="My picker"
        SemanticProperties.Description="This is the semantic properties description for the Picker"
        SemanticProperties.Hint="This is the semantic properties hint for the Picker">
    <Picker.ItemsSource>
        <x:Array Type="{x:Type x:String}">
            <x:String>A</x:String>
            <x:String>B</x:String>
            <x:String>C</x:String>
        </x:Array>
    </Picker.ItemsSource>
    </Picker>
  3. Inspect the app using Appium with platformName = Android and appium:automationName = UiAutomator2
  4. Tap the picker so that the options A, B, C show up

Expected outcome: the Picker popup elements (A, B and C) can be found in Appium using a proper method of selection. Actual outcome: the Picker popup is represented by views that are "anonymous" as seen below

image

Link to public reproduction project repository

https://github.com/hansmbakker/PickerAccessibilityBugRepro

Version with bug

8.0.0-preview.6.8686

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android API level 33

Did you find any workaround?

No response

Relevant log output

No response

hansmbakker commented 1 year ago

Adding the AutomationId does not solve this issue - the elements still remain "anonymous".