Description
Use case
The semantics identifier help in uniquely identifying elements using UI automation tools like Appium, UIAutomator and XCUITests by setting identifiers that the screen readers cannot see but the said tools can. This is especially useful when working with a multi-lingual or multi-tenant app, where the element IDs need to be unique but the content can be different. The Semantics
widget already has support for declaring it. However, the Text
and Text.rich
variants only support setting semanticsLabel
without explicitly setting the identifiers. The widgets themselves can be wrapped with a Semantics
widget but it still does not cater for a rich text that can have multiple text spans, each containing unique lables and identifiers, and optionally gesture detectors for handling links.
Consider the following UI for two different tenants:
Here, both the tenants utilise different strings to convey the same message. The structure of the message stays the same so the identifiers help in unifying the element identification process across the tenant apps in the automation tools without having to write another script for every other tenant.
Without the identifiers, the automation scripts require a rewrite per tenant to be able to successfully locate the element
Proposal
The proposed solution is to add the semanticsIdentifier
properties in Text
widget and in some of the other internal objects that deal with computing semantics information and attaching values to the semantic nodes. The changes needed, as described in PR #163843, are fairly simple and they do not have impact on any of the existing test cases.