Skip to content

Match text and labels on the DOM, as Playwright does - #1089

Merged
kblok merged 5 commits into
mainfrom
issue-1072-1074-text-query
Nov 5, 2026
Merged

kblok merged 5 commits into
mainfrom
issue-1072-1074-text-query

Conversation

@kblok

@kblok kblok commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

On the web, GetByText returned the control a label names, matched an input's placeholder, found no text inside a button, and hasText joined two adjacent blocks with a space. Upstream resolves these through Playwright on the real DOM; the port resolves them over its tree, and the tree matched accessible names and rendered (collapsed) text. Now the tree carries what Playwright reads. GetByText and hasText match the element's DOM text (no separator between blocks, a button input's value, script and style left out). GetByLabel matches the aria-label, the aria-labelledby targets and the <label> text. A label's text is listed, so the label answers a text query. A button lists the inline elements it holds, so GetByText("hello") finds the span inside it.

The three tests that #1077 kept behind ExpectedToFailAsync or [Ignore] now run as upstream wrote them (GetByLabel_should_work, GetBy_escaping, Locators_should_not_be_affected_by_global_and_sticky_regex_flags, Should_filter_by_regex_with_a_single_quote, Should_filter_by_regex_with_special_symbols). Docs and COMPATIBILITY.md say the web reads DOM text and labels.

Upstream parity

Ported: tester-army/e2e bdf769b tests selectors-get-by and locator-query (already in #1077). Upstream's labels of a raw node (web/src/in-page/read-semantics.ts, labelsOf) is labels here. No upstream test is skipped or partial in this change.

.NET-only, with reasons (upstream uses Playwright locators, the port resolves over its tree):

  • SemanticNode.DomText and domText in the page script: Playwright's element text.
  • SemanticNode.Labels (internal): the label sources of labelsOf.
  • LocatorResolver.HasText: picks DOM text when a node has it.
  • tests/E2E.Tests/TextQuery/TextQueryTests.cs: 6 tests with no upstream it; they pin the tree behavior.

Differences: a regex is tested on DOM text with whitespace collapsed; Playwright tests the raw text. As Playwright, hasText reads no input value and does not look into a nested frame. The agent's snapshot now lists a label's text beside its control, as upstream's tree does; DOM text is cut at 512 characters, as Text was.

Closes #1072
Closes #1073
Closes #1074

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ls2e1yaZFgZ3FEJkYScfkK

…loses #1073, Closes #1074)

The web engine answered getByText with the control of a label and with a placeholder, found no text inside a button, and joined adjacent blocks with a space. Text now reads the DOM text, a label query reads the label sources, and a leaf lists its inline text. The three ported tests run as upstream wrote them.

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 20 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 ee824be and 1fdb398.

Files selected for processing: 10

  • COMPATIBILITY.md
  • docs-site/src/content/docs/api/E2E/Screen.md
  • skills/e2e-dotnet/references/writing-tests.md
  • src/E2E/Engine/Observation.cs
  • src/E2E/Engine/PageScript.cs
  • src/E2E/Engine/WebEngine.cs
  • src/E2E/Locator/Screen.cs
  • tests/E2E.NUnit.Tests/LocatorQuery/LocatorQueryTests.cs
  • tests/E2E.NUnit.Tests/SelectorsGetBy/SelectorsGetByTests.cs
  • tests/E2E.Tests/TextQuery/TextQueryTests.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

…query

# Conflicts:
#	src/E2E/Locator/Screen.cs
@kblok

kblok commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

kblok and others added 2 commits November 4, 2026 21:11
…query

# Conflicts:
#	COMPATIBILITY.md
#	src/E2E/Engine/PageScript.cs
#	src/E2E/Locator/Screen.cs
…ge script does

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

kblok commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kblok
kblok merged commit bb72ae5 into main Nov 5, 2026
4 checks passed
@kblok
kblok deleted the issue-1072-1074-text-query branch November 5, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant