Skip to content

Fix Activity testing guide claim about label and placeholder locators - #100445

Merged
icyJoseph merged 3 commits into
canaryfrom
claude/activity-testing-locators
Oct 20, 2026
Merged

icyJoseph merged 3 commits into
canaryfrom
claude/activity-testing-locators

Conversation

@icyJoseph

@icyJoseph icyJoseph commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

The Testing section of the Preserving UI state guide said Playwright getByLabel and getByPlaceholder filter by visibility. They do not: with Activity keeping a hidden page in the DOM, both locators match the hidden copy and .fill() fails with a strict mode violation. Only getByRole excludes hidden elements by default.

  • Lead with the tool-agnostic rule: query the accessibility tree, or filter matches by visibility before acting
  • Keep getByRole as the default Playwright example
  • Move getByLabel / getByPlaceholder into the explicit .filter({ visible: true }) examples
  • Note that waiting for visibility does not narrow a query that matches multiple elements
  • Drop the Cypress example, which mixed a visibility assertion with a non-existent cy.get() option, and point readers to their testing tool's locator and helper docs, since this behavior varies between tools and versions

Verification

  • Playwright 1.61 against a visible form plus a display: none copy: getByLabel matched 3, getByPlaceholder matched 2 (both strict mode violations on .fill()); getByRole and the .filter({ visible: true }) variants each matched 1

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 6bccaa8

@github-actions github-actions Bot added the Documentation Related to Next.js' official documentation. label Oct 20, 2026
@icyJoseph
icyJoseph marked this pull request as ready for review October 20, 2026 12:59
@icyJoseph
icyJoseph enabled auto-merge (squash) October 20, 2026 13:11
@icyJoseph
icyJoseph merged commit f08c453 into canary Oct 20, 2026
58 checks passed
@icyJoseph
icyJoseph deleted the claude/activity-testing-locators branch October 20, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Related to Next.js' official documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants