Contents
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.
{
"action": "fill",
"selector": "[data-testid=\"input-email\"]",
"value": "john@example.com"
}That must become:
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:
{
"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:
# 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']// 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
# 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:
pytest result/tests/ --headedHow does Golem work?
1. Parse scenarios
Golem recognizes two formats.
Scout format (component-based):
{
"components": [
{
"file": "src/app/login/login.component.html",
"url": "/login",
"scenarios": [...]
}
]
}Sentinel format (URL-based):
{
"pages": [
{
"url": "http://localhost:4200/login",
"scenarios": [...]
}
]
}Golem detects the format automatically, without configuration.
2. Generate code
Golem uses Jinja2 templates for each framework:
# 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.iniSupported actions
Golem translates six types of action:
| Action | Description | Playwright | Cypress |
|---|---|---|---|
click | Click | .click() | .click() |
fill | Fill an input | .fill(value) | .type(value) |
submit | Submit a form | .click() | .submit() |
verify_visible | Check visibility | expect().to_be_visible() | .should('be.visible') |
verify_text | Check text | expect().to_contain_text() | .should('contain') |
navigate | Navigate | page.goto() | cy.visit() |
Practical example
Input: JSON scenario
{
"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
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
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)
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)
python main.py generate scenarios.json -f playwright -l typescript- ✅ For TypeScript projects
- ✅ Native async/await
3. Cypress (TypeScript)
python main.py generate scenarios.json -f cypress- ✅ Popular in the JavaScript ecosystem
- ✅ BDD-style syntax
- ✅ Real-time browser preview
4. Robot Framework
python main.py generate scenarios.json -f robot- ✅ Keyword-driven testing
- ✅ Readable by non-programmers
- ✅ Built-in reporting
5. Selenium (Python)
python main.py generate scenarios.json -f selenium- ✅ A classic that works everywhere
- ✅ Broad browser support
CLI commands
# 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.comIntegrations
1. CLI (basic use)
python main.py generate scenarios.json -f playwright2. Python library
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
# 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)
{
"mcpServers": {
"golem": {
"command": "python",
"args": ["main.py", "mcp-server"]
}
}
}In Claude:
"Generate Playwright tests from my Scout scenarios"
→ Claude calls golem_generate_testsComplete 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:
# 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:4200From 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
# 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
# Generate and run in one step
python main.py generate scenarios.json -f playwright && \
pytest result/tests/ --headed4. CI/CD ready
# .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
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:30bQuick start
# 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 chromiumUse cases
1. Multi-framework organization
# 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
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
# 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 playwrightConclusion
Golem closes the QA automation loop:
| Without Golem | With Golem |
|---|---|
| JSON scenarios → manually written tests | JSON scenarios → automatically generated tests |
| One framework = one implementation | One scenario = all frameworks |
| Hours of copying | Seconds 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.