Automation
AI
Test Automation
Automating the Migration from Selenium/Appium to Maestro

Automating the Migration from Selenium/Appium to Maestro

December 01, 2025 2 min read
šŸŽÆ

Accelerated Migration

  • From: Legacy Selenium/Appium (Imperative)
  • To: Maestro (Declarative YAML)
  • How: AST Parsing vs Regex
  • Speed: 1000s of tests converted in minutes

Organizations adopting Maestro for its speed and simplicity often face a massive hurdle: a legacy codebase of thousands of Selenium/Appium tests. Rewriting these scripts from scratch is inefficient, error-prone, and risk-heavy.

šŸ”„

The Challenge: Paradigm Mismatch

The primary challenge lies in translating imperative Python code—which supports arbitrary logic, loops, and external library calls—into declarative Maestro YAML. Python scripts often mix test steps with setup logic and complex control flows, while Maestro flows are primarily linear sequences of user actions.

The Solution: AST-Based Transpilation

Instead of simple text processing, I built a robust AST (Abstract Syntax Tree) Parser. This allows the tool to understand the structure and grammar of the Python code, ensuring accurate extraction of test intent regardless of formatting.

How It Works

  • AST Parsing: Traverses the Python source code to identify test methods, ignoring noise like driver initialization.
  • Intelligent Mapping: Maps Selenium actions to Maestro commands (e.g., `click()` → `tapOn`, `send_keys()` → `inputText`).
  • Advanced Handling: Converts `print()` statements to `runScript: console.log(...)` and `time.sleep()` to delays.
  • YAML Generation: Produces clean, valid YAML output with safety nets for unsupported actions.

Outcome

This tool effectively automates the repetitive migration work, converting typical test files in seconds. It provides accurate mapping for standard actions and intelligently flags unsupported logic for manual review, transforming a daunting migration project into a manageable process.

Dhiraj Das

About the Author

Dhiraj Das | Senior Automation Consultant | 10+ years building test automation that actually works. He transforms flaky, slow regression suites into reliable CI pipelines—designing self-healing frameworks that don't just run tests, but understand them.

Creator of many open-source tools solving what traditional automation can't: waitless (flaky tests), sb-stealth-wrapper (bot detection), selenium-teleport (state persistence), selenium-chatbot-test (AI chatbot testing), lumos-shadowdom (Shadow DOM), and visual-guard (visual regression).

Share this article:

Get In Touch

Interested in collaborating or have a question about my projects? Feel free to reach out. I'm always open to discussing new ideas and opportunities.