Playwright tests fail two ways: flaky (sleeps and fragile selectors) or unmaintainable (CSS chains that break on every restyle). This setup generates the Playwright contract for an E2E journey with the framework's own discipline: locate by user-facing attributes (getByRole, getByLabel) so restyles don't break tests, never sleep — auto-waiting and web-first assertions do the waiting, every test starts from a clean context, and page objects only where flows are actually reused.
How to use this resource
1
Generate with the journey preset
E2E strategy + Playwright mode: journey philosophy plus framework discipline in one contract.
2
Audit the locators
Every getByRole the model produces is a test that survives a restyle; every CSS chain is a future failure.
3
Reject any sleep
The contract bans fixed waits — if generated code sleeps, regenerate with the contract quoted back.
Why This Works
User-facing locators align tests with what users do, not how the DOM is shaped today
Auto-wait discipline removes the #1 source of E2E flake at the contract level
Clean-context rules keep tests independent — parallelizable and debuggable
Best for
Teams adopting Playwright from Selenium or Cypress
E2E suites where flake is the main maintenance cost
Modern web apps with accessible, role-labeled UI
Not for
Selenium projects — switch the framework mode; the discipline differs (explicit waits, stale elements)
API testing — Playwright can do it, but the API strategy with generic mode contracts it better
Use cases
Generating Playwright journeys that survive UI restyles
Converting sleep-ridden specs into auto-waiting ones
Onboarding a team to Playwright's locator philosophy
FAQ
What flow do I paste into the Playwright test prompt?
Paste the flow under test into the CODE CONTEXT block — the page or component source for one realistic journey, like the onboarding sequence in the TESTING OBJECTIVE. Include the markup or handlers that expose roles and labels so the model can pick getByRole and getByLabel locators. Anything unspecified surfaces under the ASSUMPTIONS and GAPS headings rather than being invented.
How does the getByRole and auto-wait discipline in this prompt work?
The FRAMEWORK GUIDANCE section forces two rules on whatever assistant you run it in. Locators come from user-facing attributes — getByRole, getByLabel, getByText — so a restyle can't break them, and the contract bans fixed sleeps: web-first assertions like await expect(locator).toBeVisible() do the waiting. Each test also starts from a clean context, keeping runs independent and parallelizable.
Does a passing generated Playwright test mean the feature is correct?
Passing tests prove what they assert — the COVERAGE AREAS and FAILURE SCENARIOS the file actually checks — not that the feature is correct. The NON-GOALS bar the model from weakening assertions or touching the implementation, so it tests the code as-is. Take the file the assistant returns, fix what's wrong, and confirm it goes green in CI yourself.
Build the test set an agent has to pass — scenarios across the happy path, edges, and adversarial inputs, each paired with the expected behavior to grade against.
"Fix this error" gets guesses. The investigation contract gets a ten-stage diagnosis: facts separated from assumptions, alternatives weighed, fixes justified.
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
Build test generation prompts — unit, integration, or E2E — with framework modes and edge-case coverage rules.
Coding Workflows
Tip: Save time by exploring related resources and tools that integrate with this resource.
Feedback
Send feedback to NewPrompt
Found a bug, have a suggestion, or want to report something confusing? Send a short note.
Cookie preferences
NewPrompt uses optional Google Analytics cookies to understand site usage and improve the tools.
The site works normally if you decline analytics cookies.
Read more in our Cookie Policy.