Skip to content

Read attributes of a text match inside a line - #1065

Merged
kblok merged 1 commit into
mainfrom
issue-1062-gettext-nested-span
Nov 4, 2026
Merged

kblok merged 1 commit into
mainfrom
issue-1062-gettext-nested-span

Conversation

@kblok

@kblok kblok commented Nov 4, 2026

Copy link
Copy Markdown
Member

Screen.GetByText("hello") on <div id=div1><span id=span1>hello</span>world</div> found the span but read no attributes from it, so GetAttributeAsync("id") returned null. A span read in its parent's line has no tree node of its own. The port answers a text query with a bare text node for it, and that node carried no attributes. It now carries the element's attributes, so the match reads id, class and the rest.

Upstream (tester-army/e2e bdf769b, test selectors-text) resolves getByText through a Playwright locator on the real element, so it reads the span's attributes. The port resolves text over its tree, so this fix gives the same result.

Test: ControlsTests.A_text_match_inside_a_line_reads_its_own_attributes is .NET-only. It covers the inline text node, which upstream does not have. The ported selectors-text test in #1064 still uses ExpectedToFailAsync for this step. Remove it there once this merges.

.NET-only: the attributes field on the inline text nodes in PageScript.cs. It has no upstream counterpart because upstream has no such nodes.

Closes #1062

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ls2e1yaZFgZ3FEJkYScfkK

getByText on an inline span read in its parent's line resolved to a bare text node with no attributes, so GetAttributeAsync("id") returned null. The node now carries the element's attributes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e1yaZFgZ3FEJkYScfkK
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 77f48c2 and 0ec00d1.

Files selected for processing: 2
  • src/E2E/Engine/PageScript.cs
  • tests/E2E.Tests/Controls/ControlsTests.cs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@kblok
kblok merged commit 4d70b4a into main Nov 4, 2026
4 checks passed
@kblok
kblok deleted the issue-1062-gettext-nested-span branch November 4, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getByText on text inside a mixed-content element: attribute read of the first match returns null (selectors-text, #1060)

1 participant