Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/E2E/Engine/PageScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
7 changes: 7 additions & 0 deletions tests/E2E.Tests/Controls/ControlsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
{
Expand Down
Loading