Skip to content

Add code generation for pytest and Playwright Python #12

Description

@MathiasPaulenko

Context

seleniumboot-mcp generates test code in Java/pytest/Cucumber from recorded sessions. We have wavexis_record which captures interactions as YAML, but we don't generate executable test code from it. Some users want this for test automation workflows.

What needs to happen

New tool wavexis_codegen that takes a recorded session YAML (from wavexis_record) and outputs:

  1. pytest script — using wavexis directly with assertions
  2. Playwright Python script — using playwright.sync_api
  3. Plain Python script — using wavexis directly, no test framework

Implementation

  • ~400 lines in wavexis_mcp/tools/data.py (template-based codegen)
  • Reuses the existing wavexis_record output format (YAML with actions list)
  • Add CodegenInput model to wavexis_mcp/models.py with fields:
    • yaml: str (the recorded session YAML)
    • format: str ('pytest' | 'playwright' | 'plain')
    • output_path: str | None (optional file to write)
  • Register tool in the 'data' capability tier

Example

Input (from wavexis_record):
\\yaml
actions:

Output (pytest format):
\\python
import pytest
from wavexis import BrowserOptions, CDPBackend

@pytest.mark.asyncio
async def test_recorded_session():
backend = CDPBackend(BrowserOptions(headless=True))
await backend.launch()
try:
await backend.navigate('https://example.com')
await backend.click('#login')
await backend.type('#username', 'admin@example.com')
await backend.screenshot()
finally:
await backend.close()
\\

Getting started

  1. Read wavexis_mcp/tools/data.py to see how wavexis_record works
  2. Read the YAML format it produces
  3. Create Jinja2 templates (or f-string templates) for each output format
  4. Add tests in tests/unit/test_data.py

References

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions