Skip to content
Target QATargetQA
Free Zero-Setup Migration Tool

Selenium to Playwright Converter

Convert Selenium WebDriver tests in Java, Python, or C# into clean, auto-waiting Playwright code in TypeScript, Python, JavaScript, Java, or C# instantly in your browser.

At a glance: Target QA Selenium to Playwright Converter is a free, client-side migration tool supporting Selenium Java, Python, and C# input and outputting Playwright TypeScript, Python (pytest), JavaScript, Java (JUnit 5), or C# (.NET NUnit) with WebDriverWait, Select, iFrame, and Alert translation.

Examples:
7 Selenium calls auto-mapped
import { test, expect } from '@playwright/test';

test('migrated from Selenium', async ({ page }) => {
  await page.goto('https://targetqa.com/automation-practice-form');
  await page.locator('#full-name').fill('Priya Sharma');
  await page.locator('#email-address').fill('priya@targetqa.com');
  await page.locator('#submit-practice-form').click();
  await expect(page.locator('#form-result')).toBeVisible();
});
100% browser-side conversion — your code never leaves your browser.Run in Playwright Cloud Compiler

Automatic Migration Notes

  • Removed explicit WebDriverWait declaration — Playwright auto-waits before every action and assertion.
  • Converted ExpectedConditions wait into Playwright web-first retrying visibility assertion.
  • Replaced one-shot isDisplayed() assertion with auto-retrying Playwright visibility check.

3-Step Workflow

How to Convert Selenium to Playwright

  1. 1

    Paste your Selenium Java, Python, or C# test

    Copy any Selenium WebDriver 3 or 4 method, test class, or Page Object snippet into the left editor or load one of the 4 built-in migration examples.

  2. 2

    Choose your Playwright target language

    Select Playwright TypeScript (@playwright/test), Python (pytest-playwright), JavaScript, Java (JUnit 5), or C# (.NET NUnit) — conversion updates instantaneously in your browser.

  3. 3

    Run and verify in the Playwright Online Compiler

    Copy the converted script and execute it immediately in Target QA's zero-setup cloud Chromium compiler with live console logs and 720p video replays.

What to Check After Converting

  • Upgrade brittle XPaths to semantic locators: Replace positional XPaths with getByRole(), getByLabel(), or getByTestId().
  • Register dialog & popup listeners first: In Playwright, attach page.once('dialog') or page.waitForEvent('popup') before the triggering click.
  • Delete leftover Thread.sleep calls: Playwright's auto-waiting and retrying expect() assertions eliminate hardcoded delays.
  • Verify against a live target: Test your migrated script immediately against our free Automation Practice Form inside the Playwright Online Compiler.

Migration Cheat Sheet

Selenium vs. Playwright: Exact API & Wait Mapping

Side-by-side reference covering navigation, locators, waits, dropdowns, iframes, alerts, assertions, and multi-tab windows.

Selenium WebDriver 4Playwright EquivalentMigration Tip
driver.get("https://...")await page.goto('https://...')Playwright waits for load event automatically
driver.findElement(By.id("email"))page.locator('#email')Or prefer page.getByLabel('Email')
By.cssSelector(".btn")page.locator('.btn')Playwright locators are lazy and auto-retrying
By.xpath("//button[text()=\'Save\']")page.getByRole('button', { name: 'Save' })User-facing locators resist DOM refactors
.sendKeys("hello").fill('hello')fill() clears existing text before typing
.click().click()Auto-waits for visible, stable, enabled state
new Select(el).selectByVisibleText('India')el.selectOption('India')Native selectOption() — no wrapper class needed
new WebDriverWait(driver, 10).until(visibilityOf...)await expect(locator).toBeVisible()Web-first assertions retry until timeout
driver.switchTo().frame("iframe-id")page.frameLocator('#iframe-id')Scoped — never call switchTo().defaultContent()
driver.switchTo().alert().accept()page.once('dialog', d => d.accept())Register dialog listener before trigger click
assertTrue(el.isDisplayed())await expect(el).toBeVisible()Eliminates flaky race conditions
driver.getWindowHandles()page.waitForEvent('popup')Await popup event in parallel with click

Ready to run your migrated Playwright suite online?

Execute Playwright TypeScript, Python, JavaScript, Java, or C# in real cloud Chromium with zero local installation — or solve 110+ graded Playwright exercises.

FAQ

Selenium to Playwright Migration FAQ

How does the Target QA Selenium to Playwright converter work?

Target QA's free browser-based Selenium to Playwright converter parses Selenium WebDriver Java, Python, and C# calls—including By locators, sendKeys, Select dropdowns, WebDriverWait ExpectedConditions, switchTo().frame(), and alert handling—and maps them directly into idiomatic Playwright code in TypeScript, Python, JavaScript, Java, or C#.

Is my Selenium test code uploaded to a server during conversion?

No. Conversion runs 100% locally inside your browser with zero server transmission, so proprietary enterprise test suites stay completely private.

Why does Playwright remove WebDriverWait and switchTo().defaultContent()?

Playwright performs built-in actionability auto-waiting before clicks and fills, retries web-first expect() assertions automatically, and scopes iframe interactions via frameLocator() so global frame context switching is no longer required.

Can I run my converted Playwright code online without installing Node.js or Python?

Yes. Click 'Run in Playwright Cloud Compiler' directly below the output pane to execute your converted TypeScript, Python, JavaScript, Java, or C# test inside real cloud Chromium with zero local installation.