Selenium to Playwright Migration Part 6: AI-Powered Migration With Claude Code
This is part of the Selenium to Playwright Migration Series. Follow the complete 7-part tutorial to migrate your test suite from Selenium Java to Playwright TypeScript.
๐ค Learning AI-powered testing? Go hands-on with LLM, RAG, and AI-agent testing in the AI-Powered Testing Mastery course at The Testing Academy.
Use AI to accelerate the conversion process. Claude Code and LLMs can convert 70-80% of Selenium Java tests to Playwright TypeScript automatically โ but you need to know what to validate and what requires manual intervention.
Contents
The AI Migration Prompt
Convert this Selenium Java test class to Playwright TypeScript.
Rules:
1. Replace @FindBy annotations with Playwright locators (prefer getByRole, getByLabel)
2. Remove all WebDriverWait โ Playwright auto-waits
3. Remove Thread.sleep() calls entirely
4. Convert TestNG @Test to Playwright test() blocks
5. Replace Assert.assertTrue/assertEquals with expect() assertions
6. Convert PageFactory class to Playwright Page Object (no inheritance)
7. Use async/await for all browser operations
8. Add proper TypeScript types
9. Keep the same test logic and business coverage
Input Selenium code:
[paste your code here]
CLAUDE.md for Migration Projects
# Selenium to Playwright Migration
## Project Context
We are migrating a Selenium Java + TestNG test suite to Playwright TypeScript.
## Conventions
- Use getByRole() and getByLabel() locators (never XPath)
- All page objects go in src/pages/ with .ts extension
- Tests go in src/tests/ with .spec.ts extension
- Use test.describe() for grouping, not classes
- No base classes โ use Playwright fixtures instead
- All test data in src/testdata/ as typed JSON
- Environment config via .env + src/config/index.ts
## What NOT to convert
- Do not convert WaitHelper methods โ delete them
- Do not convert RetryAnalyzer โ use config retries
- Do not convert ScreenshotListener โ use config screenshot
- Do not convert DriverManager โ Playwright handles this
๐ Build Real AI Testing Skills
Stop testing AI by guesswork. Learn DeepEval, RAG evaluation, and agent testing with guided projects.
What AI Converts Well
- Page Object class structure (remove inheritance, add locators)
- Basic test logic (click, fill, assert)
- Locator strategy conversion (By.id to page.locator)
- Assertion conversion (Assert to expect)
- Wait removal (WebDriverWait to auto-wait)
What Requires Human Review
- Complex custom frameworks and base classes
- TestNG data providers (convert to test.describe with parameterization)
- Selenium Grid configurations (replace with Playwright parallelization)
- Custom wait strategies with polling logic
- Actions class chains (map to Playwright mouse/keyboard APIs)
- Business logic verification (AI may miss domain-specific edge cases)
Validation Checklist After AI Conversion
- All XPath replaced with semantic locators (getByRole, getByLabel)
- Zero WebDriverWait or Thread.sleep remaining
- All tests run independently (no shared state)
- Assertions use expect() with auto-retry
- Page Objects have no inheritance chain
- TypeScript compiles without errors
- All tests pass in both headed and headless mode
Next: Part 7: Quick Reference Card โ the one-page migration reference you will keep on your desk.
๐ Become an AI-Powered QA Engineer
Join hundreds of SDETs mastering LLM, RAG, and agent testing. Lifetime access, hands-on labs, and a job-ready portfolio.
