Metadata-Version: 2.4
Name: qamigrate
Version: 0.3.1
Summary: AI-powered Selenium to Playwright migration tool
Project-URL: Homepage, https://github.com/qamigrate/qamigrate
Project-URL: Documentation, https://qamigrate.dev/docs
Project-URL: Repository, https://github.com/qamigrate/qamigrate
Author: QAMigrate Team
License: MIT
Keywords: ai,automation,migration,playwright,selenium,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.11
Requires-Dist: anthropic>=0.40.0
Requires-Dist: pydantic-settings>=2.5.0
Requires-Dist: pydantic>=2.9.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: rich>=13.9.0
Requires-Dist: structlog>=24.4.0
Requires-Dist: tree-sitter-java>=0.23.0
Requires-Dist: tree-sitter>=0.23.0
Requires-Dist: typer[all]>=0.12.0
Provides-Extra: dev
Requires-Dist: mypy>=1.12.0; extra == 'dev'
Requires-Dist: pre-commit>=4.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.3.0; extra == 'dev'
Requires-Dist: ruff>=0.7.0; extra == 'dev'
Description-Content-Type: text/markdown

# QAMigrate

> AI-powered test framework migration

[![PyPI version](https://img.shields.io/pypi/v/qamigrate.svg)](https://pypi.org/project/qamigrate/)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A [QATonic Innovations](https://github.com/QATonic) product.

---

QAMigrate converts test suites between frameworks automatically. It parses your code with Tree-sitter, generates equivalent code with Claude, and produces a full migration report with per-file diffs, confidence scores, and estimated time savings.

**Today:** Selenium Java -> Playwright Java
**Next:** Cypress -> Playwright, TestNG -> JUnit 5, RestAssured -> Karate, and more.

## Why QAMigrate

You don't just get generated code. You get **evidence**:

- **Per-file diffs** -- every pattern we touched, why, and side-by-side before/after
- **Confidence score** -- how sure we are about each file, 0 to 100
- **Batch report** -- HTML, JSON, and Markdown; share with your team
- **Time-saved estimate** -- how many hours of manual work you avoided
- **Dry-run mode** -- preview what would change without calling the LLM

## What it does

Give it a Selenium file:

```java
// Selenium
@FindBy(id = "username")
private WebElement usernameInput;

public void login(String user, String pass) {
    usernameInput.clear();
    usernameInput.sendKeys(user);
    passwordInput.sendKeys(pass);
    wait.until(ExpectedConditions.elementToBeClickable(loginButton));
    loginButton.click();
}
```

Get Playwright back:

```java
// Playwright (generated by QAMigrate)
private final Locator usernameInput;

public LoginPage(Page page) {
    this.usernameInput = page.locator("#username");
}

public void login(String user, String pass) {
    usernameInput.fill(user);
    passwordInput.fill(pass);
    loginButton.click(); // Playwright auto-waits
}
```

## Supported patterns (Selenium -> Playwright Java)

- `@FindBy` annotations (id, css, xpath, className, name, linkText)
- `PageFactory.initElements` removal
- `WebDriverWait` / `ExpectedConditions` removal (Playwright auto-waits)
- `sendKeys` -> `fill`, `clear` removal, `click` direct conversion
- `Actions` (hover, drag) -> Playwright equivalents
- `Select` dropdowns -> `selectOption`
- `JavascriptExecutor` -> `page.evaluate()`
- Alert / iframe handling
- File uploads -> `setInputFiles`
- TestNG -> JUnit 5 lifecycle (`@BeforeMethod` -> `@BeforeEach`, etc.)
- `@DataProvider` -> `@MethodSource`
- `Assert.assertEquals` / `assertTrue` -> Playwright assertions
- `ChromeDriver` setup -> `Playwright.create()` + `browser.newContext()`
- Base class inheritance preservation

## Quick start

### Prerequisites

- Python 3.11+
- Java 17+ (for compilation validation; optional — see `compiler.skip`)
- [Anthropic API key](https://console.anthropic.com/settings/keys)

### Install

```bash
pip install qamigrate
```

### Configure

```bash
echo "ANTHROPIC_API_KEY=sk-ant-your-key" > .env
```

### Initialize (once per project)

```bash
# Auto-injects Playwright + JUnit 5 into your pom.xml so compile-check works.
qamigrate init --project ./my-selenium-project --yes
```

### Migrate

```bash
# Dry-run: see what would happen without calling the LLM
qamigrate migrate --all --project ./my-selenium-project --dry-run

# Migrate a single file
qamigrate migrate src/test/java/LoginPage.java --project ./my-selenium-project

# Migrate the whole project with batch compile + report (recommended)
qamigrate migrate --all --project ./my-selenium-project --report ./qamigrate-report
```

Output goes to `playwright/` subdirectories next to each original file.
If you use `--report <dir>`, you get `report.html`, `report.json`, and `report.md`.

## Example report summary

```
QAMigrate - Migrating 7 file(s)

-> [1/7] BaseTest.java
   OK src/.../playwright/BaseTest.java (14.1s, 75% confidence)
-> [2/7] LoginPage.java
   OK src/.../playwright/LoginPage.java (17.2s, 75% confidence)
...

Files             7 / 7
Patterns handled  149
Avg confidence    75%
Time              105.3s
Est. hours saved  ~37.2

Report written:
  HTML:     ./qamigrate-report/report.html
  JSON:     ./qamigrate-report/report.json
  Markdown: ./qamigrate-report/report.md
```

## CLI commands

| Command | Description |
|---------|-------------|
| `qamigrate init` | Initialize QAMigrate in a project |
| `qamigrate scan` | Analyze codebase, detect patterns, show complexity |
| `qamigrate migrate` | Convert files to the target framework |

Common flags for `migrate`:
- `<file>` — migrate a single file
- `--all, -a` — migrate all Java files under `src/test` or `src/`
- `--dry-run` — analyze only, no LLM calls, no writes
- `--report <dir>` — write HTML + JSON + Markdown report
- `--project, -p <path>` — project root (default: current dir)

## How it works

```
Scanner (Tree-sitter)     Deterministic AST parsing, pattern detection
       |
Coder (Claude API)        Generates Playwright Java via structured output
       |
Compiler (javac)          Validates generated code compiles
       |
Fixer (rules + Claude)    Fixes compilation errors, retries up to 3x
       |
Report                    Records everything that happened
```

Plain Python — no LangChain, no graph framework, no agents-of-agents. Each step is a clean module you can read in 5 minutes.

## Configuration

Optional `qamigrate.yaml` in your project root:

```yaml
pipeline:
  max_retries: 3

coder:
  model: "claude-sonnet-4-20250514"
  max_tokens: 8192

compiler:
  build_tool: "maven"    # or "gradle"
  java_version: "17"
  skip: false            # set true when Playwright JARs aren't on classpath

scanner:
  exclude_patterns:
    - "**/target/**"
    - "**/build/**"
    - "**/playwright/**"
```

You can also use environment variables with the `QAMIGRATE_` prefix:

```bash
export QAMIGRATE_COMPILER__SKIP=true       # skip compilation check
export QAMIGRATE_PIPELINE__MAX_RETRIES=5   # more retries
```

## Python API

```python
from qamigrate.agents.pipeline import run_migration
from qamigrate.core.config import QAMigrateConfig
from qamigrate.core.report import MigrationReport

config = QAMigrateConfig()
report = MigrationReport()

result = run_migration(
    file_path=Path("src/test/java/LoginPage.java"),
    project_path=Path("."),
    config=config,
)

if result.record:
    report.add(result.record)

report.finish()
report.write_html(Path("./report.html"))
```

## Development

```bash
pip install -e ".[dev]"
pytest tests -v
ruff check src tests
```

## License

MIT — see [LICENSE](LICENSE).
