Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk9 min

How to Migrate from Selenium to Playwright

Move a Selenium suite to Playwright in stages: inventory dependencies, port a representative test, check locator and wait behavior, then validate isolation, browser coverage, and CI.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Migrate in stages: choose the Playwright language and runner that fit your suite, port one representative test, validate its behavior, then expand by feature area and run the result in your target CI environment. This is more than a change from Selenium method names to Playwright method names: test structure, locator behavior, waiting, isolation, and concurrency may all change. Playwright’s official migration example covers Protractor rather than Selenium, so treat the mappings below as practical guidance—not an official one-to-one conversion.

1. Inventory the Selenium suite before changing it

Make a migration inventory so decisions are based on what the tests actually depend on. Record the source language and Selenium version, test runner, browser and operating-system coverage, and whether execution uses local drivers, Selenium Server, or a remote Grid. Also note:

  • How driver creation, reuse, and cleanup work.
  • Base classes, page objects, hooks, fixtures, and shared setup.
  • Selectors and custom waits, including the condition each wait protects.
  • Authentication, frames, windows, downloads, and other browser-specific workflows used by representative tests.
  • Shared accounts or test data, ordering assumptions, retries, and parallel-job settings.
  • CI installation steps, network and authentication requirements, screenshots, logs, reports, and other failure artifacts.

This inventory is a planning aid, not a guarantee that every existing Selenium abstraction should be carried forward. Selenium WebDriver can control browsers locally or remotely through Selenium Server; compare that execution model with the environment your team needs to keep.

2. Choose the Playwright language and runner deliberately

Playwright Test is the Node.js end-to-end test runner described in the installation documentation. Its examples use asynchronous test functions, explicit imports, and fixtures such as page. If your Selenium suite is written in Java, Python, or .NET, first verify the Playwright language API and runner you intend to use. Do not paste Node.js Playwright Test syntax into another language’s test framework or translate hooks mechanically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The following worked example is for Playwright Test with Node.js. It shows the shape of a small form test; replace the example URL, labels, and expected result with elements and behavior in your own application. The test assumes a form with a label called “Email,” a “Continue” button, and a confirmation message.

Install and scaffold a Node.js Playwright Test project

  1. Install Node.js if it is not already available in the development and CI environments.
  2. In the project directory, run npm init playwright@latest and follow the prompts to select JavaScript or TypeScript, the test folder, and any workflow scaffolding. The setup can add a GitHub Actions workflow; review it rather than assuming it matches your existing CI requirements.
  3. Use the generated configuration and test file as the starting point. Keep the browser projects, timeouts, retries, and reporters that make sense for the target suite, and confirm that the selected Playwright version and browser binaries are installed in each environment.

For current setup and installation instructions, see the Playwright installation documentation.

Port one representative test

import { test, expect } from '@playwright/test';

test('submits the email form', async ({ page }) => {
  await page.goto('https://example.com/signup');
  await page.getByLabel('Email').fill('[email protected]');
  await page.getByRole('button', { name: 'Continue' }).click();
  await expect(page.getByText('Check your inbox')).toBeVisible();
});

Run it locally with npx playwright test. A useful pilot test exercises a real navigation, user interaction, and assertion, plus any setup that is representative of the suite, such as authentication, a frame, or a new window. Verify the outcome against the application; a test that passes after translation is not necessarily testing the same behavior as its Selenium predecessor.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

3. Translate selectors by intent, not by syntax

Playwright locators are evaluated against the current page when an operation uses them. Prefer locators that express how a user or an explicit test contract identifies an element. The documentation recommends user-facing choices such as role, text, label, placeholder, alternative text, or title, and permits configured test IDs when they form a deliberate contract.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Selenium concept Playwright direction Migration check
findElement(By.id(...)) or another By locator page.getByRole(...), page.getByLabel(...), page.getByTestId(...), or page.locator(...) Choose the locator based on meaning and stability; confirm it identifies the intended control.
Long CSS or XPath chain A user-facing locator or a shorter, stable CSS/XPath locator where necessary DOM-structure-dependent chains can break when markup changes. Reassess them rather than converting mechanically.
A selector matching several elements A locator that intentionally identifies one target For actions such as click, Playwright expects the locator to resolve to exactly one element. Clarify the target instead of masking ambiguity.

For example, getByRole('button', { name: 'Continue' }) says what the control is and how it is named. A locator such as locator('form > div:nth-child(2) button') encodes a particular DOM arrangement. Keep structural selectors only when they remain a stable and necessary contract for the test.

Because locators resolve against the current DOM when used, they can work naturally across a re-render. That does not make an incorrect or ambiguous locator reliable: check that the accessible name, label, or test ID actually represents the element the test is meant to use.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

4. Replace waits according to the condition they protect

Do not delete every Selenium wait, and do not translate every wait into a fixed delay. First write down what each wait proves. Playwright locator actions perform actionability checks; for a click, the locator must resolve to exactly one element, and the element must be visible, stable, able to receive events, and enabled. Web-first assertions such as await expect(locator).toBeVisible() retry until the condition passes or the timeout expires.

Selenium synchronization purpose Playwright approach What still needs review
Wait until a control is ready to click Use a locator action such as await locator.click(); it checks actionability. If the action times out, diagnose the locator and page state rather than adding an arbitrary sleep.
Wait until an element is visible or has expected text Use a retrying assertion such as await expect(locator).toBeVisible() or an appropriate text assertion. Choose an assertion that proves the intended condition, with a suitable timeout.
Wait for a business process, application state, or external service Wait for an observable condition that represents that event. Actionability only says the interaction can proceed; it does not prove that a backend job or third-party service has finished.

Retrying checks reduce the need for waits that merely duplicate readiness or visibility checks. They do not establish that every application-specific or external event has occurred. Preserve synchronization where it represents a distinct condition and make that condition explicit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Rework lifecycle and page objects around isolation

With Playwright Test, the built-in page fixture belongs to a browser context. Tests receive isolated contexts while the browser can be shared for efficiency. Fixtures provide setup and cleanup around tests, but the right migration depends on what the existing setup owns and what must be reused.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  • Map driver creation and cleanup to the target API’s browser, context, and page lifecycle; avoid preserving global mutable browser state when each test should be isolated.
  • Move setup and teardown into suitable test or fixture lifecycle points based on ownership and reuse needs, rather than matching Selenium hook names one-for-one.
  • Keep page objects if they clarify the suite. Adapt their methods to the target API’s locator and asynchronous conventions instead of discarding them just because the browser library changed.
  • Review authentication and test data setup for hidden shared state. A context boundary isolates browser state; it does not automatically isolate a shared account or backend record.

The Playwright documentation includes both fixtures and a page-object pattern. For details, consult the fixture guide and the page-object guide.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

6. Expand by feature area, then validate concurrency

Once the pilot test matches its intended behavior, migrate related tests in manageable groups: for example, a page-object area, a workflow, or a browser feature. Keep the old suite available until the new group has been checked against the same expected outcomes and relevant browser coverage.

Do not raise worker counts as an early optimization. Playwright Test runs separate test files in parallel by default, while tests within a file run in order by default. Workers are separate operating-system processes and do not share in-memory state. Before increasing concurrency, verify that tests do not depend on a shared account, mutable global fixture, ordered test data, or another shared environment assumption. Add deliberate coordination or isolation where they do.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

7. Move the suite into CI and verify the environment

Playwright Test documents support for Chromium, Firefox, and WebKit on Windows, Linux, and macOS, both locally and in CI. That coverage is not a drop-in guarantee for an existing Selenium Grid or a particular team’s remote execution architecture. Decide which browsers and operating systems the suite must cover, then verify the actual CI network access, authentication, dependencies, and artifact handling.

  1. Install the Playwright package and the matching browser binaries in the CI job, along with required operating-system dependencies for that environment. Follow the current installation instructions for the runner and platform.
  2. Configure Playwright projects to represent the browser coverage the team intends to test. Do not assume that a new default matrix matches the old Grid configuration.
  3. Set timeouts, retries, reporters, and worker behavior deliberately. Treat retries as a diagnostic and execution policy, not a substitute for resolving unstable tests.
  4. Run the migrated tests in the actual target CI environment. Check browser startup, credentials, network routes, test data, and cleanup—not just whether the tests pass on a developer workstation.
  5. Inspect the reports and failure artifacts configured for the suite. Decide how screenshots, logs, or traces will be retained and made available to the team.

The Playwright Test setup can offer workflow scaffolding, including GitHub Actions, but exact CI edits depend on your platform and environment. Review the Playwright CI guidance alongside your own execution requirements.

8. Troubleshoot common migration failures

Symptom Likely cause Practical fix
A locator action times out. The locator is wrong or ambiguous, the expected element never appears, or the element does not meet actionability requirements. Check the locator against the current UI, confirm uniqueness, and inspect whether the expected state actually occurs. Avoid replacing diagnosis with a fixed sleep.
A click fails because more than one element matches. The locator describes several controls instead of a unique target. Use a more specific role/name, label, or test ID, and make the intended target explicit.
An assertion passes too early or never passes. The assertion may describe the wrong signal, or the application condition differs from the Selenium wait’s condition. Compare the old wait’s exact condition with the new assertion. Assert the user-visible outcome or other relevant state, not merely that an action was attempted.
Tests pass alone but fail in a full or parallel run. They may share accounts, backend data, global state, or ordering assumptions. Run related tests together, identify shared resources, isolate or coordinate them, then adjust worker counts after independence is demonstrated.
Tests work locally but browsers fail to launch in CI. CI may lack the matching Playwright browser binaries, required dependencies, network access, or environment-specific configuration. Install the documented browser binaries and dependencies in the job, then verify the CI platform’s credentials and network routes.
A migration becomes a large rewrite before behavior is proven. Too many test areas or abstractions were changed at once. Return to one representative test, validate its behavior, and expand in bounded feature-area batches.

9. Take a screenshot without changing your test runner

For a screenshot needed outside the migration itself—for example, a one-off page capture—ScreenshotNeo is a website screenshot API and MCP server. It is not a replacement for Playwright Test or a migration tool. It can be useful when you need a clean captured image without setting up a separate browser script.

Or skip the browser setup

Make one GET request with a URL to receive an image or PDF. This cURL example saves a WebP screenshot of the target URL; see the ScreenshotNeo API documentation for request options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response indicates the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

The free plan includes 1,000 screenshots per month with no card required. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Try ScreenshotNeo and sign up for 1,000 free screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.