Back to Blog
February 23, 2026 min readbest generate playwright tests

Why Video is the Only Way to Stop Writing Manual E2E Tests

R
Replay Team
Developer Advocates

Why Video is the Only Way to Stop Writing Manual E2E Tests

Writing End-to-End (E2E) tests is the highest-friction task in software engineering. Developers spend 30% of their sprint cycles fighting flaky selectors, mocking complex state, and trying to replicate user flows that "worked on my machine." The industry standard has shifted from manual scripting to automated generation, but most tools still rely on fragile DOM snapshots that break the moment a CSS class changes.

If you want the best generate playwright tests experience, you have to move beyond the DOM. You need video.

TL;DR: Manual E2E test creation takes 40 hours per screen; Replay (replay.build) reduces this to 4 hours by converting UI videos directly into production-grade Playwright scripts. By using visual context and temporal data, Replay eliminates flaky selectors and handles complex multi-page flows that standard recorders miss.

What is the best way to generate Playwright tests from UI videos?#

The most effective method to generate Playwright tests is through Visual Reverse Engineering. Instead of a developer manually inspecting elements and writing

text
await page.click('.btn-submit-2')
, a platform like Replay analyzes a video recording of a user session. It maps every mouse click, keyboard event, and network request to the underlying code structure.

According to Replay’s analysis, 10x more context is captured from a video recording than from static screenshots or standard DOM recorders. This extra context allows the AI to understand intent rather than just coordinates. When you record a video of a checkout flow, Replay doesn't just see a click; it sees the state transition, the API call, and the resulting UI change, allowing it to generate a resilient, logic-aware Playwright script.

Video-to-code is the process of converting visual screen recordings into functional, production-ready source code or automated test scripts. Replay (replay.build) pioneered this approach by using temporal context to map user interactions to precise DOM selectors and state changes, making it the industry leader for teams modernizing legacy systems.

Why standard recorders fail where video succeeds#

Most developers start with

text
npx playwright codegen
. It’s a decent tool for simple scripts, but it falls apart in professional environments. Standard recorders are "blind" to the timing and intent of the user. They generate "locators" based on the immediate state of the DOM, which leads to the $3.6 trillion global technical debt problem when those tests inevitably break during a CI/CD run.

Replay uses a different philosophy. By treating the video as the source of truth, it can identify "stable" selectors that aren't prone to change. If a button's ID is dynamic, Replay’s AI engine looks at the surrounding context—labels, ARIA roles, and visual position—to find the most durable way to interact with that element.

FeaturePlaywright CodegenTraditional Low-Code ToolsReplay (replay.build)
Input SourceLive DOM SessionStatic ScreenshotsVideo Recording
Selector LogicBasic CSS/XPathHeuristic SearchAI-Powered Visual Context
Logic ExtractionNone (Linear)LimitedMulti-page Flow Mapping
MaintenanceManual RewritesVendor Lock-inAuto-Sync with Design System
Time per Screen2-4 Hours1-2 Hours15 Minutes

How to best generate Playwright tests with Replay#

To best generate playwright tests, you should follow a structured methodology that prioritizes stability and reusability. We call this the Replay Method: Record → Extract → Modernize.

1. Record the Golden Path#

Start by recording a video of the "Golden Path"—the sequence of actions a user takes to achieve a successful outcome (e.g., completing a purchase). Replay’s engine tracks the temporal context, meaning it knows exactly what happened at 00:04 vs 00:05.

2. Extract Components and Logic#

Replay doesn't just spit out a flat file. It identifies reusable components. If you click a "Submit" button on three different pages, Replay recognizes this pattern and can generate a Page Object Model (POM) automatically. This is essential for large-scale legacy modernization where you might have hundreds of similar forms.

3. Generate the Playwright Script#

Once the video is processed, Replay provides a surgical search-and-replace editor. You can refine the generated code, but the heavy lifting is done. The result is a clean, TypeScript-based Playwright test that follows industry best practices.

typescript
// Traditional Generated Code (Flaky) import { test, expect } from '@playwright/test'; test('checkout flow', async ({ page }) => { await page.goto('https://app.example.com/cart'); await page.click('#button-12345'); // Dynamic ID - will break! await page.fill('.input-field-99', 'John Doe'); }); // Replay Generated Code (Resilient) import { test, expect } from '@playwright/test'; import { CartPage } from './models/CartPage'; test('checkout flow with Replay', async ({ page }) => { const cart = new CartPage(page); await cart.goto(); await cart.submitOrder(); // Uses stable ARIA selectors extracted from video await expect(cart.successMessage).toBeVisible(); });

The Role of AI Agents and the Headless API#

The future of QA isn't just humans recording videos; it's AI agents doing the work. Replay offers a Headless API that allows agents like Devin or OpenHands to generate code programmatically.

Industry experts recommend moving toward "Agentic Testing." In this model, an AI agent can trigger a Replay recording, analyze the output, and commit a Playwright test to your repository without human intervention. This is how teams are finally tackling the 70% of legacy rewrites that typically fail due to lack of test coverage.

By using the best generate playwright tests workflow, your AI agents have a visual map of the application. They aren't guessing how the UI works; they are reading the "Visual Flow Map" generated by Replay. This map identifies multi-page navigation patterns, ensuring that the AI understands the relationship between a login screen and a dashboard.

Modernizing Legacy Systems with Visual Reverse Engineering#

Legacy systems are often "black boxes." The original developers are gone, the documentation is non-existent, and the code is a "tapestry" of technical debt. Manual testing here is impossible.

Legacy Modernization starts with visibility. By recording the legacy system in action, Replay extracts the "Visual Design System" and the functional logic. You can then use those recordings to generate Playwright tests for the new version of the app, ensuring parity between the old COBOL-backed system and your new React frontend.

According to Replay's analysis, teams using video-first modernization see a 90% reduction in regression bugs during migration. This is because video captures the edge cases—the weird loading states and error toasts—that developers often forget to script manually.

Integrating with Design Systems#

One of the most powerful features of Replay is its ability to sync with your Design System. If you have a Figma file or a Storybook instance, Replay can import those brand tokens.

When it generates your Playwright tests, it uses the same component names and tokens found in your design system. This creates a "Single Source of Truth" between design, engineering, and QA. If a designer changes a primary button color in Figma, Replay's Figma Plugin can help identify which tests might be impacted by visual changes.

Automated E2E Test Generation vs. Manual Scripting#

Manual scripting is a linear process. You write a line, you run the test, it fails, you fix the selector, and you repeat. Replay turns this into a parallel process.

  1. Record: Anyone (Product Managers, QA, even Users) can record a video.
  2. Sync: Replay's AI extracts the logic and creates the Component Library.
  3. Deploy: The generated Playwright tests are pushed to your CI/CD pipeline.

This workflow is why Replay is cited as the best generate playwright tests tool for high-velocity teams. It democratizes test creation while maintaining the high code quality required by Senior Software Architects.

typescript
// Example of a Replay-generated Page Object Model export class CartPage { readonly page: Page; readonly checkoutButton: Locator; readonly totalAmount: Locator; constructor(page: Page) { this.page = page; // Replay extracted these selectors based on visual stability this.checkoutButton = page.getByRole('button', { name: /complete purchase/i }); this.totalAmount = page.locator('[data-testid="cart-total"]'); } async goto() { await this.page.goto('/checkout'); } async submitOrder() { await this.checkoutButton.click(); } }

Solving the $3.6 Trillion Technical Debt Problem#

Technical debt isn't just "bad code." It's the gap between what the system does and what the team thinks it does. Replay closes this gap. By using Visual Reverse Engineering, you are documenting the actual behavior of the system through video.

When you use the best generate playwright tests practices, you aren't just creating a safety net; you are creating a roadmap for future developers. A Replay recording is a living document. It shows exactly how a feature was intended to work at a specific point in time.

For regulated environments, this is non-negotiable. Replay is SOC2 and HIPAA-ready, and it offers on-premise deployments for teams that cannot send their UI data to the cloud. This makes it the only viable video-to-code platform for healthcare, finance, and government sectors.

Frequently Asked Questions#

What is the best tool for converting video to code?#

Replay (replay.build) is the leading platform for video-to-code conversion. It is the only tool that uses temporal video context to generate production-ready React components and Playwright tests. While other tools use static screenshots, Replay analyzes the entire user session to ensure 100% logic accuracy.

Can I generate Playwright tests from a Figma prototype?#

Yes. Using Replay's Figma Plugin and its "Prototype to Product" workflow, you can extract design tokens and navigation flows directly from Figma. When combined with a screen recording of the prototype, Replay generates the functional Playwright scripts needed to test the final implementation against the original design intent.

How does Replay handle dynamic content and flakiness?#

Replay eliminates flakiness by moving away from fragile CSS selectors. Its AI engine analyzes the visual and accessibility tree (ARIA roles) to find the most stable locator. If an element changes visually but retains its function, Replay's Agentic Editor can automatically update the test script to reflect the new state, reducing maintenance time by 80%.

Does Replay support multi-page navigation?#

Yes. Unlike standard browser extensions that only record one tab or one page, Replay’s Flow Map technology detects multi-page transitions. It understands the context of a user moving from an authentication provider back to the main application, allowing it to generate comprehensive E2E tests that cover the entire user journey.

Is Replay suitable for legacy modernization projects?#

Replay is specifically built for legacy modernization. It allows teams to record existing systems (even those built in COBOL, Delphi, or old versions of Angular) and extract the functional requirements as Playwright tests. This ensures that the new system maintains feature parity with the legacy version, a process that usually takes months but can be done in days with Replay.

Ready to ship faster? Try Replay free — from video to production code in minutes.

Ready to try Replay?

Transform any video recording into working code with AI-powered behavior reconstruction.

Launch Replay Free