Skip to content

Migrate Selenium to Playwright

QualityMax uses Playwright for browser automation. A Selenium migration happens in your repository and should preserve test intent before optimizing implementation. Inventory languages, drivers, page objects, fixtures, grids, browser targets, and CI jobs before converting files.

from selenium.webdriver.common.by import By
def test_sign_in(driver):
driver.get("https://staging.example.com/login")
driver.find_element(By.NAME, "email").send_keys("[email protected]")
driver.find_element(By.NAME, "password").send_keys("example-password")
driver.find_element(By.CSS_SELECTOR, "button[type=submit]").click()
assert "/dashboard" in driver.current_url
import { test, expect } from '@playwright/test';
test('sign in', async ({ page }) => {
await page.goto('https://staging.example.com/login');
await page.getByLabel('Email').fill('[email protected]');
await page.getByLabel('Password').fill('example-password');
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page).toHaveURL(/\/dashboard/);
});

Run with npx playwright test. Keep credentials in your approved secret store, never in a test file.

Playwright locators and assertions auto-wait for actionable state, so remove implicit waits and most explicit WebDriverWait calls rather than copying them. Convert Selenium page objects to objects that receive a Playwright Page; map frames to frameLocator(), windows to page or context events, and ActionChains to locator, mouse, or keyboard actions.

Run Selenium and Playwright against the same environment until test counts, assertions, browser coverage, data setup, and CI artifacts match. Only then remove WebDriver dependencies and grid configuration. Import the proven Playwright scripts into QualityMax or manage them through the CLI workflow.