-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] AutomationId no longer works #4714
Comments
Is there an ETA for this issue being fixed? |
I don't think this is something that we are going to be able to change. Using contentDesc for AutomationId was a very incorrect decision because it completely breaks accessibility. Basically what you say here
Is what breaks on Android accessibility wise. My recommendations here would be to either
|
@PureWeen do you have an example of option 1 you have mentioned? |
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new AppShell();
#if ANDROID
ViewHandler.ViewMapper.ModifyMapping("AutomationId", (handler, view, previousAction) =>
{
if (view is Android.Views.View androidView)
{
androidView.SetTag(42, view.AutomationId);
}
});
#endif
}
} |
I realise the initial issue was for Android but is there equivalent code for the other platforms (iOS, MacOS and Windows) or are they not affected by the change and can still use AutomationId ? |
iOS/Windows/MacOS shouldn't be affected because all of those platforms have a specific property for this purpose and we still map AutomationId to those. Android is the only one that doesn't provide anything here for us to use. |
Hi @PureWeen This is troubling for me:
I read this as: The most important property for testability (and every QA) will never work for Android. It seems like developers have to choose between testability or accessibility, but you are not giving us the option to do that. For some testability is more important than accessibility. Also, can you please share how do you write your automation tests? Do you use AutomationId or something else? P.S. The workaround is not so feasible as the ViewHandler.ViewMapper.ModifyMapping method is not called for controls that have their own Mapper, event if it is based on the ViewHandler. For example it is not called for ContentView or ImageButton and for them it should be done separately. This is tedious, there is no documentation and I am spending days just to be able to do something as simple as setting an AutomationId and continue with creating a basic test for a MAUI app, while in Xamarin there weren't such issues.
|
The difficulty you ran into with hooking into Mappers definitely needs to be remedied We'll need to review the cases with Appium a bit more. Because I see that even in appium's documentation they reference content-desc . Does searching by Tag not work for your scenario? |
@PureWeen any timelines to review the cases with Appium? This is blocking us from writing automation for our product app. |
@amolbhushan can you switch to using tag? The other option here would be to add your own attached property and then you can add a mapper for that property that you map to contentDesc #if ANDROID
ViewHandler.ViewMapper.ModifyMapping("OurAutomationId", (handler, view, previousAction) =>
{
if (view is Android.Views.View androidView)
{
androidView.ContentDescription = view.AutomationId;
}
});
#endif |
Not sure what you mean by using tag? |
Appium has a few different ways beyond the contentDesc for searching for elements Tag being one of them |
Hi @PureWeen Appium has a server-client architecture, where the Appium server is started and communicates with the client (called driver). For each platform (Android, iOS, etc.) there is a different driver. Each driver under the hook is using the given platform Automation framework. For example for iOS the XCUITest Driver is using the XCTest that comes with Xcode. Anyway, here is more info on what we are trying to achieve with Appium and Maui.
Looking forward to your replay. |
@GeorgeDarakchiev I don't currently have Appium setup locally. Can you test if this works I implemented this code based on what I found here If this doesn't work can you send the project back to me with Appium setup and failing? Also, thank you for taking the time to give me such thorough explanations :-) I haven't done a lot with Appium so our current workaround is based on Xamarin.UITests which works fine but Xamarin.UITest uses a different mechanism for searching than Appium does :-/ |
I can confirm that contend-description is set with the AutomationId from the App. Also you can easily inspect the app without having to create tests or some fancy Appium setup. You just need to follow the steps below:
Then you will be able to inspect the app and see the tree, whether elements have content description and search for elements. |
@GeorgeDarakchiev so the above zip file worked for you? You were able to use |
@StuartFerguson @amolbhushan @GeorgeDarakchiev Does the project here make it so AutomationId's work for you on appium? @GeorgeDarakchiev |
Yes, it works in the project. |
Description
When AutomationId is set to any MAUI element\view it is not set as a ContentDescription to the Android element\view.
You can find project showing the issue here: https://github.com/GeorgeDarakchiev/ReproProjects/tree/main/AutomationIdRepro/AutomationIdRepro
It seems like it is caused by PR: #3835 where there is
else if (info.ContentDescription == virtualView.AutomationId) info.ContentDescription = null;
Anyway, this leads to UI Automation frameworks (like Appium) not being able to locate elements by Automaton\Accessibility Id (depending on the naming in the framework).
In this image you can see on the left how it was before, and on the right how it is now (no content description)
Steps to Reproduce
Version with bug
Preview 12 (current)
Last version that worked well
Preview 11
Affected platforms
Android
Affected platform versions
All
Did you find any workaround?
As a workaround SemanticProperties.Description can be set, but this leads to issues on iOS.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: