Test migration

Migrating from Selenium to Playwright: what does it involve?

Moving a suite from Selenium to Playwright requires preserving valid scenarios and assertions and assessing technical dependencies. If unstable selectors or fixed pauses drive the decision, compare migration costs with repairing the existing suite.

A common assumption is that the suite will be “rewritten”: each test is taken in turn and translated into the new language. A mechanical rewrite tends to be expensive and can carry the original suite’s weaknesses into the new tool.

Common problem: a literal rewrite also migrates old weaknesses

The suite’s value lies primarily in its valid scenarios and assertions: knowledge about how the product should behave, what should happen after a form is submitted, what message should appear for an invalid payment, and which input combinations have failed in the past. The code, integrations, and diagnostic mechanisms need to be assessed separately, because they too may contain reusable parts or technical constraints.

During migration, we establish which waits, selectors and shared components need a new design.

We therefore select the valid scenarios and assertions from the old suite and assess the code, integrations, and diagnostics separately. We neither migrate them automatically nor discard them all without review.

How to migrate valuable scenarios

First, we review the current suite and determine what it actually covers. We retire tests of removed features after confirming their invalidity. For scenarios skipped for years, we first establish why they were skipped and whether they remain relevant. Others test the same thing three times in different ways. It is useful to identify this before work begins as well.

We migrate the rest onto a foundation designed for easier maintenance:

The migration proceeds gradually by priority, with critical journeys first. The old and new suites can run side by side for a period, and a coverage map identifies which one checks each regression scenario. This avoids a planned period without checks of all agreed critical journeys.

What the new foundation gives you

Before actions, Playwright performs element-readiness checks and supports retrying assertions. This can remove many fixed waits. Stability still depends on the data, environment, selectors, and scenario design.

Playwright supports projects for several browser engines. Depending on the configuration, it can save a screenshot, video, or trace when a test fails to help with diagnostics. Not every output is created automatically under every configuration.

We write the new suite in a language that fits your team, most often Python, or TypeScript if the tests should live alongside the frontend. We integrate it with CI/CD from the first migrated scenario, not only at the end of the project.

List technical dependencies before the pilot

Migrating tools does not necessarily mean changing languages. Playwright also supports Java and .NET, although testing ecosystems differ. Staying with the team’s language can preserve some knowledge and helper functions. Moving to Python requires reviewing fixtures, reporting and CI as well as browser automation. Playwright Test for TypeScript and pytest-playwright for Python are different runners.

Part of the old suite What to assess before migration
Expected-value calculations and data generation Is the logic still valid and independent of WebDriver?
Page objects Which methods describe a process and which return old element objects?
Grid and browser provider Do they support the required environment, versions and new connection method?
CI hooks and reports Who prepares data, collects evidence and restores state after failure?

Playwright’s Selenium Grid 4 integration is experimental and supports Chrome and Edge. It does not automatically transfer every existing Grid combination. Verify required browsers and infrastructure separately. WebKit support also does not establish coverage of every specific Safari version.

Transfer the condition the test was waiting for

Selenium offers implicit and explicit waits. A fixed pause is a suite design decision, rather than an unavoidable property of Selenium. Its documentation also warns against mixing implicit and explicit waits. During the audit, establish whether fixing existing synchronisation would solve the problem.

In Playwright, use locators that find the current element for an action and appropriate result assertions. For a form, distinguish an available button from a completed server-side write. Waiting for Save to be visible does not replace checking the correct price and record state after saving. Click auto-waiting does not itself know these business rules.

If the old test used a particular frame or tab, transfer that context too. Finding similar text on the main page can produce a green result without checking the original process. Verify the new locator’s uniqueness, rather than simply that it found something.

A model pilot with two roles

Choose record creation by an authorised user and refusal of the same operation for a user without permission. Give the old and new tests the same build and rules but separate accounts and data identifiers. Their concurrent runs then do not intentionally share one draft record.

For the permitted operation, verify the saved record’s contents. For the refused operation, verify the expected error and absence of an unauthorised write. In an isolated environment, prepare a model incorrect response and confirm that the new assertion fails. Restore the correct state and repeat the run alone and alongside the rest of the pilot suite.

Measure first attempts, retries, total time including setup and investigation time. A comparison is invalid if the new version tests only the successful role or replaces a real write with a simpler mock without declaring the difference. This pilot is a proposal, rather than an executed client migration.

What acceptance of the new suite should establish

The number of transferred files is insufficient. Each critical scenario needs a traceable original purpose, new assertions, browsers, data setup, owner and known limitations. Retired tests need a documented reason confirmed by the responsible person.

Before disabling the old job, verify the new CI run, diagnostics for a controlled failure and recovery after interruption. For Python, prepare supported browsers and pytest integration, rather than only a library on the author’s machine. The team should be able to reproduce the run from documentation and maintain an ordinary form change. If a critical journey remains uncovered, assign a temporary check and declare it when making a release decision.

When migration does not make sense

If you have a large Grid infrastructure and a team that knows Selenium well, leaving it may not be the right decision. In that case, it may be better to change only the architecture or language and keep the tool. If the suite is sound but merely unstable, it is often less expensive to repair it than to migrate it.

We will tell you when migration is not worthwhile too.

Next step

Show us the current suite and tell us what causes the most pain. Contact us and we will assess what is worth migrating, what to discard, and in which order.

Related topics

You might also be interested in

We will preserve the years of knowledge stored in your tests

Is your suite built with an unsupported tool or written in a language nobody in the company understands? We migrate it gradually and reduce the risk of gaps in key checks.