Writing Playwright End-to-End Tests With LLMs in October 2026: Show the Model the Real Page, Ban Fixed Sleeps, and Prove Every Test Can Fail
Ask a chat model to "write a Playwright test for our login page" and you will get something that looks finished in a few seconds. It will have a test() block, a few page.click() calls, and an assertion at the end. Run it a few times in CI and the problems show up: selectors that match the wrong element, hard-coded sleeps that fail on slow runners, and assertions that pass even when the feature is broken. End-to-end (E2E) tests drive a real browser through your real app, so they catch problems that unit tests can't. They are also the most expensive tests to keep healthy. An LLM can save you a lot of typing here, but only if you give it the right inputs and hold its output to a few firm rules. This guide walks through a workflow that works with any current model and with Playwright's TypeScript API. The same ideas carry over to Cypress or Selenium. Why E2E tests are hard for a model to get right A model writing a unit test can see the function it is testing. A m...