Contents
Golem: Turning JSON Scenarios into Executable Playwright Tests

Golem: Turning JSON Scenarios into Executable Playwright Tests

You have generated test scenarios in JSON. Now what? Someone must rewrite them in Playwright, Cypress or Robot Framework. By hand.

json
{
  "action": "fill",
  "selector": "[data-testid=\"input-email\"]",
  "value": "john@example.com"
}

That must become:

python
page.locator("[data-testid=\"input-email\"]").fill("john@example.com")

For 100 scenarios with 500 steps, that is hours of tedious work.

Golem solves this by automatically generating executable test code from JSON scenarios.

The problem: from scenario to test

Scout and Sentinel generate JSON scenarios:

json
{
  "name": "Successful login",
  "steps": [
    {"action": "fill", "selector": "[data-testid='input-email']", "value": "user@test.com"},
    {"action": "fill", "selector": "[data-testid='input-password']", "value": "secret123"},
    {"action": "click", "selector": "[data-testid='btn-login']"},
    {"action": "verify_visible", "selector": "[data-testid='dashboard']"}
  ]
}

But JSON is not a test. You need a Playwright Python, Cypress TypeScript, Robot Framework or Selenium test. Each framework has different syntax:

python
# Playwright
page.locator("[data-testid='btn-login']").click()

# Selenium
driver.find_element(By.CSS_SELECTOR, "[data-testid='btn-login']").click()

# Robot Framework
Click Element    css:[data-testid='btn-login']
typescript
// Cypress
cy.get("[data-testid='btn-login']").click()

Manual rewriting wastes time.

The solution: Golem, an intelligent test-code generator

Golem converts scenarios into executable code:

JSON scenarios (Scout/Sentinel)
         ↓
       GOLEM
         ↓
┌────────┬────────┬────────┬──────────┐
│Playwright│ Cypress │ Robot  │ Selenium │
│ Python  │   TS    │Framework│  Python  │
└────────┴────────┴────────┴──────────┘

One command gives you tests

bash
# Generate Playwright tests from JSON scenarios
python main.py generate scenarios.json -f playwright --base-url http://localhost:4200

# Output:
# ✅ Generated 47 test files
# ✅ 156 test cases
# ✅ Saved to: result/tests/

Run them immediately:

bash
pytest result/tests/ --headed

How does Golem work?

1. Parse scenarios

Golem recognizes two formats.

Scout format (component-based):

json
{
  "components": [
    {
      "file": "src/app/login/login.component.html",
      "url": "/login",
      "scenarios": [...]
    }
  ]
}

Sentinel format (URL-based):

json
{
  "pages": [
    {
      "url": "http://localhost:4200/login",
      "scenarios": [...]
    }
  ]
}

Golem detects the format automatically, without configuration.

2. Generate code

Golem uses Jinja2 templates for each framework:

python
# Internal logic (simplified)
def translate_step(step, framework):
    if framework == "playwright":
        if step.action == "click":
            return f'page.locator("{step.selector}").click()'
        elif step.action == "fill":
            return f'page.locator("{step.selector}").fill("{step.value}")'
    elif framework == "cypress":
        if step.action == "click":
            return f'cy.get("{step.selector}").click()'
        # ...

3. Save tests

result/
├── tests/
│   ├── test_login.py
│   ├── test_contact.py
│   ├── test_dashboard.py
│   └── conftest.py
└── pytest.ini

Supported actions

Golem translates six types of action:

ActionDescriptionPlaywrightCypress
clickClick.click().click()
fillFill an input.fill(value).type(value)
submitSubmit a form.click().submit()
verify_visibleCheck visibilityexpect().to_be_visible().should('be.visible')
verify_textCheck textexpect().to_contain_text().should('contain')
navigateNavigatepage.goto()cy.visit()

Practical example

Input: JSON scenario

json
{
  "name": "Successful contact form submission",
  "description": "User fills and submits contact form",
  "page_url": "/contact",
  "steps": [
    {
      "action": "fill",
      "selector": "[data-testid='input-name']",
      "value": "John Doe",
      "description": "Fill name field"
    },
    {
      "action": "fill",
      "selector": "[data-testid='input-email']",
      "value": "john@example.com",
      "description": "Fill email field"
    },
    {
      "action": "fill",
      "selector": "[data-testid='textarea-message']",
      "value": "Hello, this is a test message.",
      "description": "Fill message field"
    },
    {
      "action": "click",
      "selector": "[data-testid='btn-submit']",
      "description": "Click submit button"
    },
    {
      "action": "verify_visible",
      "selector": "[data-testid='success-toast']",
      "description": "Verify success message"
    }
  ]
}

Output: Playwright Python test

python
import pytest
from playwright.sync_api import Page, expect


def test_successful_contact_form_submission(page: Page, base_url: str):
    """User fills and submits contact form"""
    
    # Navigate to contact page
    page.goto(f"{base_url}/contact")
    
    # Fill name field
    page.locator("[data-testid='input-name']").fill("John Doe")
    
    # Fill email field
    page.locator("[data-testid='input-email']").fill("john@example.com")
    
    # Fill message field
    page.locator("[data-testid='textarea-message']").fill("Hello, this is a test message.")
    
    # Click submit button
    page.locator("[data-testid='btn-submit']").click()
    
    # Verify success message
    expect(page.locator("[data-testid='success-toast']")).to_be_visible()

Alternative: Cypress TypeScript test

typescript
describe('Contact Form', () => {
  it('Successful contact form submission', () => {
    // User fills and submits contact form
    
    cy.visit('/contact');
    
    // Fill name field
    cy.get("[data-testid='input-name']").type('John Doe');
    
    // Fill email field
    cy.get("[data-testid='input-email']").type('john@example.com');
    
    // Fill message field
    cy.get("[data-testid='textarea-message']").type('Hello, this is a test message.');
    
    // Click submit button
    cy.get("[data-testid='btn-submit']").click();
    
    // Verify success message
    cy.get("[data-testid='success-toast']").should('be.visible');
  });
});

One scenario, different frameworks, one Golem command.

Supported frameworks

1. Playwright (Python)

bash
python main.py generate scenarios.json -f playwright -l python
  • ✅ A popular modern framework
  • ✅ pytest integration
  • ✅ Auto-wait and screenshots on failure
  • ✅ Multiple browser support

2. Playwright (TypeScript)

bash
python main.py generate scenarios.json -f playwright -l typescript
  • ✅ For TypeScript projects
  • ✅ Native async/await

3. Cypress (TypeScript)

bash
python main.py generate scenarios.json -f cypress
  • ✅ Popular in the JavaScript ecosystem
  • ✅ BDD-style syntax
  • ✅ Real-time browser preview

4. Robot Framework

bash
python main.py generate scenarios.json -f robot
  • ✅ Keyword-driven testing
  • ✅ Readable by non-programmers
  • ✅ Built-in reporting

5. Selenium (Python)

bash
python main.py generate scenarios.json -f selenium
  • ✅ A classic that works everywhere
  • ✅ Broad browser support

CLI commands

bash
# Generate tests
python main.py generate scenarios.json \
  --framework playwright \
  --language python \
  --base-url http://localhost:4200 \
  --output ./tests

# Analyze scenarios
python main.py parse scenarios.json -v
# Output:
# Total pages: 12
# Total scenarios: 47
# Total steps: 234
# Source format: Scout

# Preview test (without saving)
python main.py preview scenarios.json --page contact-form

# Run tests
python main.py run ./tests \
  --headed \
  --browser firefox \
  --base-url http://staging.app.com

Integrations

1. CLI (basic use)

bash
python main.py generate scenarios.json -f playwright

2. Python library

python
from scenario_parser import ScenarioParser
from test_generator import TestGenerator
from test_runner import TestRunner

# Parse
parser = ScenarioParser()
parsed = parser.parse_file("scenarios.json")
print(f"Found {parsed.total_scenarios} scenarios")

# Generate
generator = TestGenerator(framework="playwright", language="python")
generator.generate_from_parsed(parsed, base_url="http://localhost:4200")
generator.save_tests("tests/")

# Run
runner = TestRunner(framework="playwright")
results = runner.run("tests/", headed=True)
print(f"Passed: {results.passed}, Failed: {results.failed}")

3. gRPC server

bash
# Start the server
python main.py grpc-server --port 50053

# Calls:
# - GenerateTests(scenarios_file, framework, base_url)
# - ParseScenarios(scenarios_file)
# - GetStatus()

4. MCP server (Claude integration)

json
{
  "mcpServers": {
    "golem": {
      "command": "python",
      "args": ["main.py", "mcp-server"]
    }
  }
}

In Claude:

"Generate Playwright tests from my Scout scenarios"
→ Claude calls golem_generate_tests

Complete QA toolchain

Golem is the last piece of the puzzle:

┌─────────────────────────────────────────────────────┐
│                     MARKER                           │
│   Adds data-testid to components                  │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌──────────────────────┴──────────────────────────────┐
│                                                      │
│  ┌─────────────┐              ┌─────────────┐       │
│  │   SCOUT     │              │  SENTINEL   │       │
│  │ (from code)    │              │ (from UI)      │       │
│  │             │              │             │       │
│  │ Static    │              │ Dynamic   │       │
│  │ analysis     │              │ analysis     │       │
│  └──────┬──────┘              └──────┬──────┘       │
│         │                            │              │
│         └──────────┬─────────────────┘              │
│                    ↓                                 │
│           JSON scenarios                              │
│                                                      │
└────────────────────┬────────────────────────────────┘
                     ↓
┌─────────────────────────────────────────────────────┐
│                     GOLEM                            │
│   JSON → Playwright/Cypress/Robot/Selenium          │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│              EXECUTABLE TESTS                       │
│   pytest / cypress run / robot                      │
└─────────────────────────────────────────────────────┘

Practical end-to-end workflow:

bash
# 1. Marker: Add data-testid
python marker/main.py add --project ./frontend

# 2. Scout: Generate scenarios from code
python scout/main.py generate ./frontend -o scenarios.json

# OR Sentinel: generate scenarios from the running app
python sentinel/main.py --url http://localhost:4200 -o scenarios.json

# 3. Golem: Generate Playwright tests
python golem/main.py generate scenarios.json -f playwright

# 4. Run tests
pytest result/tests/ --base-url http://localhost:4200

From source code to running tests in four commands.

Why Golem?

1. Framework-agnostic scenarios

One JSON scenario
      ↓
   GOLEM
      ↓
├── Playwright tests (CI/CD)
├── Cypress tests (frontend team)
├── Robot tests (QA team)
└── Selenium tests (legacy)

You do not write tests repeatedly: generate them for different frameworks.

2. Consistent syntax

python
# All tests have the same structure
def test_scenario_name(page: Page, base_url: str):
    """Description from scenario"""
    page.goto(f"{base_url}/page")
    # Steps...
    expect(...).to_be_visible()

3. Immediate execution

bash
# Generate and run in one step
python main.py generate scenarios.json -f playwright && \
pytest result/tests/ --headed

4. CI/CD ready

yaml
# .github/workflows/tests.yml
- name: Generate tests from scenarios
  run: python golem/main.py generate scenarios.json -f playwright

- name: Run tests
  run: pytest result/tests/ --base-url ${{ env.STAGING_URL }}

Configuration

env
# .env
SCENARIOS_FILE=scenarios.json
OUTPUT_DIR=result
TEST_FRAMEWORK=playwright
TEST_LANGUAGE=python
TEST_BROWSER=chromium
HEADLESS=true
BASE_URL=http://localhost:4200

# Server
GRPC_PORT=50053

# Optional LLM (for future AI enhancements)
OLLAMA_HOST=http://localhost:11434
LLM_MODEL=qwen3-coder:30b

Quick start

bash
# 1. Install dependencies
pip install playwright pytest pytest-playwright
playwright install chromium

# 2. Have scenarios? (from Scout or Sentinel)
# If not:
python scout/main.py generate ./frontend -o scenarios.json

# 3. Generate tests
python main.py generate scenarios.json \
  --framework playwright \
  --base-url http://localhost:4200

# 4. Run tests
pytest result/tests/ --headed

# 5. (Optional) Headless for CI/CD
pytest result/tests/ --browser chromium

Use cases

1. Multi-framework organization

bash
# QA prefers Robot Framework
python main.py generate scenarios.json -f robot -o qa-tests/

# Developers prefer Playwright
python main.py generate scenarios.json -f playwright -o dev-tests/

# The legacy system uses Selenium
python main.py generate scenarios.json -f selenium -o legacy-tests/

2. CI/CD pipeline

yaml
jobs:
  test:
    steps:
      - name: Generate from latest scenarios
        run: |
          python scout/main.py generate ./src -o scenarios.json
          python golem/main.py generate scenarios.json -f playwright
      
      - name: Run tests
        run: pytest result/tests/

3. Framework migration

bash
# Old Selenium tests → new Playwright tests
# 1. Export scenarios from existing tests (manually or scripted)
# 2. Golem generates new tests
python main.py generate legacy-scenarios.json -f playwright

Conclusion

Golem closes the QA automation loop:

Without GolemWith Golem
JSON scenarios → manually written testsJSON scenarios → automatically generated tests
One framework = one implementationOne scenario = all frameworks
Hours of copyingSeconds of generation

When to use Golem:

  • ✅ You have Scout/Sentinel scenarios and need tests
  • ✅ Teams use different testing frameworks
  • ✅ A CI/CD pipeline needs automated tests
  • ✅ Migrating between testing frameworks

Golem is the bridge between scenarios and executable tests. AI writes scenarios with Scout or Sentinel; Golem generates tests; you review the results.


Golem is part of a QA automation toolchain: Marker → Scout/Sentinel → Golem → tests. The tools work together to automate the QA process.

All articles