Skip to main content
Automation TestingBlogs

How to Migrate Tests from Selenium to Playwright with Zero Downtime

By December 22, 2025No Comments5 min read
Migrate Tests from Selenium to Playwright

Migrating from Selenium to Playwright doesn’t have to be an all-or-nothing move. Many teams hesitate to begin the transition because their existing test suite is too important to pause or modify abruptly.  

This guide provides a clear approach to creating a hybrid testing setup that executes Selenium and Playwright tests side-by-side within the same CI pipeline using simple shell scripts.  

This ensures a smooth migration process with zero downtime, while keeping the current testing workflow fully operational. 

Why Run Both Frameworks Together? 

1. Zero down time: Continue running your existing Selenium tests while migration begins.
2. Gradual migration: Convert tests at your own pace without pressure.
3. Risk mitigation: Test Playwright in CI environments without abandoning Selenium.
4. Team flexibility: Allow different team members to work on different frameworks during the transition.
5. Functional parity validation: Run the same test in both frameworks to verify consistency and confirm results.

Project Structure 

test-automation/
├── selenium-tests/
│   └── test_login.py
├── playwright-tests/
│   └── test_login.spec.js
└── scripts/
    └── run_all_tests.sh 

Note: Each framework maintains its own dependencies, configuration, and test runner to avoid version conflicts during migration. 

The Shell Script Solution 

Below is a simple shell script to execute Selenium and Playwright tests together. 

#!/bin/bash

echo “=========================================”
echo “Running Hybrid Test Suite”
echo “=========================================”

# Run Selenium Tests
echo “Running Selenium Tests…”
cd selenium-tests || exit 1
python -m pytest test_login.py
SELENIUM_EXIT=$?

# Run Playwright Tests
echo “Running Playwright Tests…”
cd ../playwright-tests || exit 1
npx playwright test
PLAYWRIGHT_EXIT=$?

# Summary
echo “=========================================”
echo “Selenium: $([ $SELENIUM_EXIT -eq 0 ] && echo ‘PASSED’ || echo ‘FAILED’)”
echo “Playwright: $([ $PLAYWRIGHT_EXIT -eq 0 ] && echo ‘PASSED’ || echo ‘FAILED’)”

# Exit with failure if either suite failed
[ $SELENIUM_EXIT -eq 0 ] && [ $PLAYWRIGHT_EXIT -eq 0 ]
 

This simple script: 

  • Executes Selenium tests. 
  • Executes Playwright tests. 
  • Reports the status of both frameworks. 
  • Returns appropriate exit codes for seamless CI/CD integration. 

Example 

Selenium Test (Python) 

# test_login.py
from selenium import webdriver

def test_login():
    driver = webdriver.Chrome()
    driver.get(“https://example.com”)
    driver.find_element(“id”, “username”).send_keys(“user”)
    assert “Welcome” in driver.page_source
    driver.quit() 

Playwright Test (JavaScript) 

// test_login.spec.js
const { test, expect } = require(‘@playwright/test’);

test(‘login test’, async ({ page }) => {
  await page.goto(‘https://example.com’);
  await page.fill(‘#username’, ‘user’);
  await expect(page.locator(‘text=Welcome’)).toBeVisible();
});
  

Running Your Tests 

Make the script executable and run it: 

chmod +x scripts/run_all_tests.sh
./scripts/run_all_tests.sh 

CI/CD Integration 

Add this to your GitHub Actions, Jenkins, or any CI tool: 

# .github/workflows/tests.yml 

– name: Install Playwright Browsers 

 run: npx playwright install –with-deps 

– name: Run Tests
  run: ./scripts/run_all_tests.sh

Migration Strategy: Step-by-Step 

Weeks 1–2: Setup 

  • Establish the hybrid project structure. 
  • Add the shell script to run both frameworks. 
  • Verify that Selenium and Playwright tests execute successfully. 

Weeks 3–4: Start Small 

  • Begin writing new tests in Playwright only. 
  • Keep all existing Selenium tests running without disruption. 

Months 2–3: Migrate Critical Tests 

  • Convert the most important test cases to Playwright. 
  • Run both Selenium and Playwright versions in parallel to validate results. 
  • Remove the Selenium version once confidence is established. 

Month 4 and Beyond: Complete Migration 

  • Gradually convert remaining Selenium tests to Playwright. 
  • Delete Selenium tests as their Playwright tests stabilize. 
  • Eventually remove all Selenium dependencies entirely. 

Advanced: Selective Execution 

Add a parameter to run specific frameworks: 

#!/bin/bash
MODE=${1:-both}

if [ “$MODE” = “selenium” ] || [ “$MODE” = “both” ]; then
    cd selenium-tests && python -m pytest
fi

if [ “$MODE” = “playwright” ] || [ “$MODE” = “both” ]; then
    cd playwright-tests && npx playwright test
fi
  

Usage: 

./run_all_tests.sh selenium   # Run only Selenium
./run_all_tests.sh playwright # Run only Playwright
./run_all_tests.sh both       # Run both (default)

Key Benefits of This Approach 

  • No special tools required: Runs using simple shell scripts. 
  • Cross-platform compatibility: Works on Linux, Mac, Windows (Git Bash), and CI/CD environments. 
  • Easy to maintain: Straightforward for any team member to understand and manage. 
  • Flexible: Supports additional features like logging, reporting, and notifications as needed. 
  • Safe: Allows testing with Playwright without impacting existing Selenium tests. 

Common Pitfalls to Avoid 

  • Avoid running tests concurrently: Execute tests sequentially to prevent port conflicts. 
  • Don’t skip validation: Continue running both versions of migrated tests for a period to ensure accuracy. 
  • Avoid migrating everything at once: A gradual approach is safer and more reliable. 
  • Don’t ignore flaky tests: Address and fix flaky tests during the migration process. 

Conclusion 

Running Selenium and Playwright side-by-side removes the uncertainty often associated with migration. This approach allows teams to transition gradually, test thoroughly, and maintain confidence throughout the process. 

By starting with a simple shell script, a hybrid testing framework can be up and running within minutes—no complex setup, no framework lock-in, just a practical and efficient path forward. 

Next Steps 

  • Copy the shell script structure. 
  • Add a single Playwright test. 
  • Run both Selenium and Playwright tests together. 
  • Begin the gradual migration process with confidence. 

Amid today’s accelerated development cycles, migration delays and test gaps can slow releases and impact product quality.  

Building a robust hybrid framework that bridges legacy Selenium with modern Playwright is the solution—a challenge our team at Testrig Technologies handles with expertise. 

We help teams: 

  • Implement seamless migration strategies with zero disruption to CI/CD pipelines. 
  • Accelerate test modernization through reliable and maintainable automation practices. 
  • Train QA engineers on Playwright best practices and advanced testing patterns. 

Ready to transform your testing into a strategic business advantage? 

Whether you need a team to kickstart your Migrate Tests from Selenium to Playwright initiative or modernize legacy test automation, Testrig Technologies, a leading automation testing company, is your trusted partner for seamless transitions and sustained quality excellence.