Q8 of 21 · AI for testing
How would you use AI to migrate a test suite from one framework to another?
Short answer
Short answer: Use AI to do the mechanical conversion — Selenium to Playwright, for example — at a file-by-file level. Provide the source file, the target language and framework, and your conventions. Review every converted locator and assertion individually; AI doesn't know whether the locator still resolves in the new architecture.
Detail
AI handles the boilerplate of syntax conversion well: changing driver.findElement(By.id("foo")).click() to page.getByTestId("foo").click() is pattern substitution a model does reliably. Where it breaks down is in decisions that require understanding: choosing the right Playwright locator strategy for a given element, or recognising that a Selenium explicit wait can be replaced with Playwright's auto-wait rather than another explicit wait.
Practical workflow for a large migration:
- Convert one file at a time rather than the whole suite.
- Prompt with target conventions: "Use
getByRoleandgetByLabelwhere possible. Avoid raw CSS selectors." - Run the converted test immediately and fix what the model got wrong before moving to the next file.
- Use migration as an opportunity to clean up flaky patterns rather than converting them.
See Legacy to modern migrations for a full migration playbook.