fix(web): resolve id: selectors against Flutter's flt-semantics-identifier#3323
Open
MrEdgarsz wants to merge 1 commit into
Open
fix(web): resolve id: selectors against Flutter's flt-semantics-identifier#3323MrEdgarsz wants to merge 1 commit into
MrEdgarsz wants to merge 1 commit into
Conversation
…ifier On Flutter web, Semantics(identifier:) is emitted as the flt-semantics-identifier DOM attribute, but a node's resource-id was built from node.id (an internal flt-semantic-node-N that changes between frames), so id: selectors never resolved it. Prefer the attribute when present, falling through to the existing chain for non-Flutter pages. Adds a self-contained data: URL web flow that exercises it.
736079b to
a844d2d
Compare
Author
|
Revised the e2e after the first CI run. Swapped the served demo-app flow for a self-contained data: URL flow in the date_input.yaml style, so it runs in CI with no server or build. Also fixed a yaml parse slip in the flow name that was failing the suite. The change is now just the maestro-web.js fix plus that one web flow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
I hit this while writing Maestro flows against a Flutter web app:
id:selectors just never match anything. The reason turned out to be a bit sneaky. When you setSemantics(identifier: 'login_button')in Flutter, the web engine puts that on aflt-semantics-identifierDOM attribute, but Maestro builds a node'sresource-id(whatid:actually looks at) fromnode.id, and on Flutternode.idis an internal handle likeflt-semantic-node-7that gets reassigned between frames. So there's nothing stable to target, andtapOn: { id: ... }just times out.The change makes
maestro-web.jsreadflt-semantics-identifierfirst when it's present:Why
Flutter web is the one place
id:is basically unusable. The identifier you set in code doesn't land in the DOMid, it goes into a separate attribute Maestro wasn't looking at. Once it reads that attribute,Semantics(identifier:)behaves the way you'd already expectid:to. That matters more on Flutter than elsewhere, since most text is painted on canvas and labels drift, so a stableid:is really the only reliable selector.Design notes
I tried to keep this as small and boring as possible:
node.id || ariaLabel || …chain is untouched. The new attribute is just tried first, and on any page that doesn't have it the expression falls through to exactly the old behaviour.flt-semantics-identifieronly ever shows up on Flutter web, so nothing changes for any other web app.resource-idout of this script, so they both pick it up from the one change.Worth flagging: Flutter web only emits its semantics tree once accessibility is enabled, so the attribute isn't in the DOM until then. The demo screen turns it on with
ensureSemantics()(web only).Testing
I added a screen and a flow to the demo app so this is easy to run yourself.
lib/semantics_identifier_screen.dartwraps a button inSemantics(identifier: 'login_button'), and.maestro/web_flows/flutter_semantics_identifier.yamlmatches and taps it purely byid:, then checks the tap actually fired. With the patch it passes. Onmainit fails at theid: login_buttonassertion.I also checked a plain non-Flutter page still resolves
id:(vianode.id) anddata-testidexactly as before, and:maestro-client:test/:maestro-web:testare green.Issues fixed
Nothing filed on my end, and I didn't find any in the issues tab that talk about this problem.