Migrating from Selenium or Cypress to Playwright: A Practical Comparison
Switching test frameworks is one of the highest-risk decisions a QA team makes. The wrong approach leads to months of parallel maintenance, duplicated tests, and a half-migrated suite that nobody trusts. This guide walks through the practical considerations for moving to Playwright from Selenium or Cypress, including when the migration is worth it and when it is not.
“Teams that run both frameworks in parallel during migration report up to 50% test redundancy, with the old suite catching bugs the new one misses and vice versa.”
Testing Framework Migration Survey, 2025
1. When Migration Actually Makes Sense
Not every team should migrate. If your Selenium or Cypress suite is stable, well-maintained, and covers your critical paths, the cost of migration may not be justified. Framework migration makes sense when you are hitting fundamental limitations: Selenium tests that are consistently slow despite optimization, Cypress tests that cannot handle your application's multi-tab workflows, or either framework struggling with modern web features like Web Workers, Service Workers, or complex iframe interactions.
The most common trigger for Selenium migration is speed. Selenium WebDriver communicates with browsers through HTTP, adding network latency to every command. Playwright uses the Chrome DevTools Protocol (CDP) and similar native protocols for Firefox and WebKit, which means commands execute within the browser process rather than over a network connection. In practice, teams migrating from Selenium to Playwright report 2x to 5x faster test execution depending on test complexity and network conditions.
For Cypress teams, the trigger is usually architectural limitations. Cypress runs inside the browser, which gives it excellent debugging capabilities but restricts it to a single browser tab and a single origin. If your application opens OAuth popups, payment provider redirects, or new tabs for document previews, Cypress requires workarounds that add complexity and reduce test reliability. Playwright handles these scenarios natively because it controls the browser from outside, giving it access to all tabs, contexts, and origins simultaneously.
Before committing to migration, audit your existing suite. Count the tests that work reliably, the tests that are flaky, and the scenarios you cannot test with your current framework. If the untestable scenarios are critical user paths (like checkout with a third-party payment modal), migration has clear business value. If the main complaint is just developer preference, the ROI is harder to justify.
2. Architecture Differences That Affect Your Tests
The biggest adjustment for Selenium users is Playwright's auto-waiting behavior. In Selenium, you write explicit waits: WebDriverWait(driver, 10).until(element_is_visible). In Playwright, every action automatically waits for the element to be visible, enabled, and stable before interacting with it. This eliminates an entire category of flaky tests caused by race conditions, but it also means you need to remove your existing wait logic during migration rather than porting it directly. Ported Selenium waits layered on top of Playwright's auto-waits create unnecessarily slow tests.
For Cypress users, the shift is from a chainable command queue to async/await. Cypress commands are enqueued and executed sequentially, which means you never write await in Cypress test code. Playwright is fully async: every browser interaction returns a Promise that you must await. This is a mechanical translation, but teams that rush it introduce subtle bugs where they forget to await an action and the test proceeds before the action completes.
Browser context isolation is another significant difference. Playwright creates isolated browser contexts for each test by default, which means tests do not share cookies, localStorage, or session state. Selenium and Cypress both default to a shared browser session, so teams often have implicit dependencies between tests (a login test that runs first and sets up session state for subsequent tests). During migration, you need to make each test self-contained or explicitly set up state using Playwright's storageState feature.
Skip the manual rewrite
Assrt generates fresh Playwright tests from your running app. No need to translate Selenium or Cypress line by line.
Get Started →3. The Cypress Ceiling: Multi-Tab and Cross-Origin
Cypress's single-tab, single-origin architecture is its most discussed limitation, and it is the primary reason teams migrate to Playwright. Consider a standard e-commerce checkout: the user clicks "Pay with PayPal," a popup opens to the PayPal domain, the user authenticates, and the popup closes returning the user to the merchant site. In Cypress, you cannot interact with that popup because Cypress only controls one tab at one origin. The standard workaround is to stub the payment API at the network level, which tests your integration code but not the actual payment flow.
Playwright handles this natively. You listen for the popup event on the page, interact with the new page object, complete the payment flow, and verify the result back on the original page. The test exercises the real user path, including the redirect timing and state synchronization between windows. This is not a marginal improvement; it is the difference between testing what you shipped and testing an approximation.
Similar limitations surface with OAuth flows (Google, GitHub, Apple sign-in), document preview windows, and any feature that opens content in a new tab. Cypress has added experimental multi-origin support through cy.origin(), but it still operates within a single tab and requires explicit origin declarations. Playwright's browser context model treats multiple pages as first-class objects with no special syntax required.
If your application does not use popups, OAuth redirects, or multi-tab workflows, this limitation may never affect you. Evaluate your specific use case rather than migrating based on general capability comparisons.
4. Incremental Migration Strategies
The safest migration approach runs both frameworks in parallel. Keep your existing Selenium or Cypress suite running in CI while building the Playwright suite alongside it. Start by migrating your most critical tests (login, checkout, core workflows) and verify that the Playwright versions catch the same failures. Only retire the old tests once the new ones have proven reliable over several weeks of production deployments.
A practical timeline for a suite of 200 to 500 tests is 8 to 12 weeks. In the first two weeks, set up the Playwright project structure, configure CI integration, and migrate 10 to 15 smoke tests. In weeks three through six, migrate feature tests in priority order, starting with the tests that cover your highest revenue paths. In weeks seven through ten, migrate the remaining tests and address edge cases. Weeks eleven and twelve are for parallel validation: both suites run on every PR, and you investigate any disagreements between them.
One risk during parallel running is maintenance overhead. Every bug fix and new feature requires tests in both frameworks until migration is complete. To reduce this burden, write new tests only in Playwright from the start of migration. The old suite covers existing functionality while the new suite covers new work. Over time, the old suite becomes a static regression safety net that you can retire test by test as the Playwright suite catches up.
5. Accelerating Migration with AI Test Generation
The most time-consuming part of migration is rewriting test logic, not because the logic is complex, but because there is a lot of it. Each test needs its selectors updated, its wait strategies replaced, and its assertions translated to Playwright's syntax. AI test generation tools can accelerate this significantly by generating a fresh Playwright test suite from your running application rather than translating the old suite line by line.
Assrt takes this approach: point it at your staging URL with npx @m13v/assrt discover https://your-app.comand it crawls the application, identifies test scenarios, and generates standard Playwright test files. Instead of mechanically translating 300 Cypress tests to Playwright syntax, you get a fresh suite generated from the user's perspective. This often discovers test gaps that the original suite missed, since the AI agent explores the application without the assumptions built into hand-written tests.
Other tools serve similar roles in different ways. Playwright's built-in code generator (npx playwright codegen) records browser interactions and outputs test code, though it requires manual effort for each test. QA Wolf offers a managed service where their team writes and maintains your Playwright tests, though at $7,500 per month it targets enterprises rather than startups. Momentic generates tests from natural language descriptions but uses proprietary YAML format rather than standard Playwright code.
Regardless of the tooling you choose, the key principle is to treat migration as an opportunity to improve your test suite, not just to translate it. A direct port preserves all the limitations and blind spots of the original suite. Generating fresh tests from the application's current behavior creates a suite that reflects what users actually do today, which is almost certainly different from what the original tests were written to verify.
Migrate to Playwright faster
Assrt generates a fresh Playwright test suite from your running application. No line-by-line translation needed.