Open hansmbakker opened 1 year ago
Button
(good)Picker
(bad)Adding to this:
The Picker
is represented by an EditText
view on Android in unfocused state. When it is tapped to show its options, it is replaced in-place by a set of different views that do not have an id anymore. This makes it very awkward to use in UI tests.
Related bug https://github.com/dotnet/maui/issues/1186 - this one was reproduced bug closed. I cannot comment there anymore, but probably would be good to have that one reopened
@hansmbakker You need to use AutomationId to locate elements
https://github.com/dotnet/maui/issues/8277
We use an AccessibilityDelegate a few places in Android
to manage accessibility to work around some bugs in Android
so we don't always propagate those to content-desc
Hi @hansmbakker. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@PureWeen
AutomationId
to the Picker
indeed translates to the id
on Android. However, having this work with accessibility id
would be really welcome as it seems to be the recommended approach in Appium to select elementsAutomationId
to the Picker
does not work for the popup that shows the picker options (#16284)@PureWeen I saw you added https://github.com/dotnet/docs-maui/issues/1577 - this would be really welcome to have some insight in how to more effectively write UI tests!
Description
The Semantic Properties are the recommended way in MAUI to add accessibility metadata.
On Android (have not tested on other platforms yet), this does not work consistently across all controls making it harder to make UI tests.
For a
Button
control, this works correctly. TheSemanticProperties.Description
XAML is translated to thecontent-desc
field//android.widget.Button[@content-desc="My semantic properties description"]
and Appium will interpret that correctly as theaccessibility id
. TheSemanticProperties.Hint
XAML is correctly translated to thehint
field.Bug For the
Picker
control this does not work. TheSemanticProperties.Hint
XAML attributes is propagated to the resulting Android app but theSemanticProperties.Description
is not.Instead, the
SemanticProperties.Description
is emitted as thetext
property of theEditText
view that represents thePicker
control in Android.Steps to Reproduce
Button
and aPicker
like so:platformName
=Android
andappium:automationName
=UiAutomator2
Expected outcome: the
Picker
can be found in Appium using theaccessibility id
which can be set bySemanticProperties.Description
in XAML Actual outcome: theSemanticProperties.Description
is propagated as thetext
property of theEditText
view in AndroidLink 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?
Use XPath to find an element, which is not recommended.
Relevant log output
No response