next.js
f08c4536 - Fix Activity testing guide claim about label and placeholder locators (#100445)

Commit
47 days ago
Fix Activity testing guide claim about label and placeholder locators (#100445) ## 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 <!-- NEXT_JS_LLM -->
Author
Parents
Loading