Skip to content
CodeKru

Generate

Selenium to Playwright Converter

Paste a Selenium test or page object in Java, Python, C# or JavaScript and get the Playwright version in Java, Python or JavaScript.

Selenium source
Playwright target

Ready to convert

Paste Selenium on the left and convert to generate Playwright here.

About the converter

Convert Selenium tests to Playwright in seconds

Moving a test suite from Selenium WebDriver to Playwright means rewriting every driver call, locator, wait and assertion. This free converter does that rewrite for you. It keeps your test logic and flow, and it can switch language at the same time, for example Selenium Java to Playwright JavaScript.

How to convert Selenium to Playwright

  1. Pick the language of your Selenium code and the Playwright language you want.
  2. Paste a test class, a page object or a single method, then click Convert.
  3. Copy the Playwright code, review it, and run it before you commit.

Selenium code in

  • Java
  • Python
  • C#
  • JavaScript

Playwright code out

  • Java
  • Python
  • JavaScript

Any source works with any target: 12 combinations. TypeScript projects can use the JavaScript output.

Selenium vs Playwright: what changes

The main differences the converter handles, and the ones to keep in mind after you migrate.

  • Waiting

    Selenium: Explicit waits (WebDriverWait) or sleeps before you act

    Playwright: Actions wait until the element is visible, stable and enabled

  • Locators

    Selenium: By.id, By.cssSelector, XPath

    Playwright: page.locator() with CSS or XPath, plus getByRole and getByText

  • Assertions

    Selenium: Read a value, then assert with your test framework

    Playwright: Web-first expect() / assertThat() that retries until it passes

  • Browsers

    Selenium: A driver per browser, such as ChromeDriver or GeckoDriver

    Playwright: Installs and drives Chromium, Firefox and WebKit itself

  • Test isolation

    Selenium: Usually a new browser per test

    Playwright: A lightweight browser context per test

  • Network

    Selenium: Needs a proxy, Chrome DevTools or WebDriver BiDi to mock requests

    Playwright: Built-in request mocking with page.route()

Selenium Java vs Playwright JavaScript, side by side

The same steps in both APIs. Change the languages in the converter to see another pair.

Your Selenium Java code

Selenium Java tests call WebDriver through driver.findElement(By...), wait with WebDriverWait and ExpectedConditions, and handle dropdowns with the Select class. They usually run under JUnit or TestNG.

The Playwright JavaScript result

Playwright JavaScript usually runs under @playwright/test: each test() gets a fresh page, actions wait for the element on their own, and expect() retries until the assertion passes.

  • Open a page

    Selenium Java: driver.get("https://example.com");
    Playwright JavaScript: await page.goto('https://example.com');
  • Click a button

    Selenium Java: driver.findElement(By.id("submit")).click();
    Playwright JavaScript: await page.locator('#submit').click();
  • Type into a field

    Selenium Java: driver.findElement(By.name("q")).sendKeys("playwright");
    Playwright JavaScript: await page.locator('[name=q]').fill('playwright');
  • Read text

    Selenium Java: String text = driver.findElement(By.cssSelector(".title")).getText();
    Playwright JavaScript: const text = await page.locator('.title').textContent();
  • Wait for an element

    Selenium Java: new WebDriverWait(driver, Duration.ofSeconds(10))
        .until(ExpectedConditions.visibilityOfElementLocated(By.id("result")));
    Playwright JavaScript: await page.locator('#result').waitFor();
  • Pick a dropdown option

    Selenium Java: new Select(driver.findElement(By.id("country")))
        .selectByVisibleText("India");
    Playwright JavaScript: await page.locator('#country').selectOption({ label: 'India' });
  • Close the browser

    Selenium Java: driver.quit();
    Playwright JavaScript: await browser.close();

What to check after converting

  • Delete explicit waits that only wait for an element to appear. Playwright actions such as click() and fill() already wait for the element.
  • Swap assertions on read-back text for web-first checks (await expect(locator).toHaveText(...)), which retry until they pass.
  • Move setup and teardown from JUnit or TestNG to the @playwright/test runner.
  • The language changes from Java to JavaScript too. Check helper classes, test data and string formatting by hand.

Run the code online

Paste the converted code and run it in a real browser, with nothing to install.

Frequently asked questions

Is the Selenium to Playwright converter free?

Yes. It is free and needs no account. You can run up to 30 conversions a minute.

Which languages does it support?

Selenium code in Java, Python, C# or JavaScript, converted to Playwright Java, Python or JavaScript. Any source works with any target, so you can switch language while you migrate.

Can it convert page objects?

Yes. @FindBy fields and other stored elements become Playwright locators, created inside the methods that use them.

Does it convert a whole test suite?

It converts the code you paste, one test class or page object at a time. Update shared helpers, configuration and build files (pom.xml, requirements.txt, package.json) yourself.

Is the converted code ready to run?

It is usually close, but it is AI-generated, so review it and run it before you commit. You can try it in the free Playwright compilers on this site.

What happens to the code I paste?

It is sent to an AI model to convert it and is kept in our logs. Do not paste passwords, API keys or private URLs.

Can I use the output in a TypeScript project?

Yes. The JavaScript output runs in a TypeScript project; add types where your setup needs them.