diff --git a/src/E2E/Engine/PageScript.cs b/src/E2E/Engine/PageScript.cs index 693fd3330..f0506d0e5 100644 --- a/src/E2E/Engine/PageScript.cs +++ b/src/E2E/Engine/PageScript.cs @@ -869,13 +869,14 @@ internal static class PageScript // The inline elements read in the element's line that have no node of // their own, as bare nodes of text under it, so a text query still // finds a word the line carries, as Playwright's text engine does. + // They carry their attributes, so a read of the match finds its id. // They stay out of the tree the agent reads. const inlineNodesOf = (parent, isHidden) => { const out = []; for (const child of renderedChildrenOf(parent)) { if (child.nodeType !== Node.ELEMENT_NODE || !flowsInLine(child) || listed(child, roleOf(child))) continue; const text = cut(lineRunOf(child), Infinity); - if (text) out.push({ ref: stamp(child), text, hidden: isHidden, rect: rectOf(child), children: inlineNodesOf(child, isHidden) }); + if (text) out.push({ ref: stamp(child), text, hidden: isHidden, attributes: attributesOf(child, false), rect: rectOf(child), children: inlineNodesOf(child, isHidden) }); } return out; }; diff --git a/tests/E2E.Tests/Controls/ControlsTests.cs b/tests/E2E.Tests/Controls/ControlsTests.cs index ef99df85d..ca18cf77f 100644 --- a/tests/E2E.Tests/Controls/ControlsTests.cs +++ b/tests/E2E.Tests/Controls/ControlsTests.cs @@ -323,6 +323,13 @@ public Task A_hidden_twin_is_skipped_by_a_visible_query_and_reached_by_index() = Assert.True(await banner.Last().IsVisibleAsync()); }); + [Fact] + public Task A_text_match_inside_a_line_reads_its_own_attributes() => RunAsync(async screen => + { + // The badge span is read in the item's line, so it has no node of its own; its match still answers for it. + Assert.Equal("badge", await screen.GetByText("urgent").First().GetAttributeAsync("class")); + }); + [Fact] public Task Filters_narrow_a_list_by_text_or_a_nested_match_and_nth_picks_one_row() => RunAsync(async screen => {