Skip to content

Add semanticsIdentifier to Text and TextSpans for unique identification through UI automation tools #163842

Closed
@ashishbeck

Description

@ashishbeck

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:
Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions