Contents
Marker: AI That Adds data-testid Across a Project in Five Minutes

Marker: AI That Adds data-testid Across a Project in Five Minutes

Do you know the feeling when an automation engineer asks for data-testid on every button and input, and you realize you have 200 components that need manual changes?

Marker solves this with one command.

The problem: why do we need data-testid?

Modern testing frameworks such as Cypress, Playwright and Testing Library recommend data-testid rather than CSS selectors:

typescript
// ❌ Fragile: breaks when styles change
await page.click('.btn-primary.submit-form');

// ❌ Fragile: breaks when text changes
await page.click('text=Submit');

// ✅ Stable: survives refactoring
await page.click('[data-testid="button-contact-submit"]');

Why data-testid is better:

  • ✅ Independent of CSS classes, so you can change styles
  • ✅ Independent of text, so you can localize
  • ✅ Explicitly marks testable elements
  • ✅ Survives component refactoring

The reality in practice

Adding IDs is tedious, repetitive work:

html
<!-- Before -->
<button class="btn-primary">Submit</button>
<input type="email" placeholder="Email">
<a href="/home">Home</a>

<!-- After: manually added -->
<button class="btn-primary" data-testid="button-contact-submit">Submit</button>
<input type="email" placeholder="Email" data-testid="input-contact-email">
<a href="/home" data-testid="a-navbar-home">Home</a>

Time required:

1 component = 5–10 minutes (find elements, choose names, add IDs)
100 components = 8–16 hours of work
+ a need for consistent naming
+ code review
= frustration for the whole team

The solution: Marker, an AI-powered test ID generator

Marker is a Python tool that:

  1. Scans your Angular, React or Vue frontend project
  2. Identifies elements without data-testid
  3. Uses a local LLM to generate semantic IDs
  4. Applies changes to files, with rollback support
bash
# One run = the whole project
python main.py add --project /path/to/frontend

# Result: all interactive elements have data-testid

How does it work?

Pipeline:

Frontend project
      ↓
FileAnalyzerAgent
├── Scans .html, .jsx, .tsx, .vue
├── Ignores node_modules, dist, .git
└── Extracts context from the file path
      ↓
TestIdGeneratorAgent
├── Regex detection of elements without test IDs
├── Batch processing for the LLM
├── Ollama + Qwen3-Coder model
└── Fallback IDs if the LLM fails
      ↓
BackupManager
├── Backup before changes
├── Timestamped manifest
└── Rollback support
      ↓
Modified files with data-testid

Which elements does Marker process?

python
TARGET_ELEMENTS = [
    "button",    # Buttons
    "input",     # Input fields
    "select",    # Select boxes
    "a",         # Links
    "form",      # Forms
    "textarea",  # Text fields
    "table"      # Tables
]

Marker ignores elements that already have data-testid; it does not overwrite them.

Naming convention

Marker generates IDs in a semantic structure:

{element-type}-{component-name}-{description}

Examples:

ElementContextGenerated ID
<button>Submit</button>hero.component.htmlbutton-hero-submit
<input type="email">login.component.htmlinput-login-email
<a href="/">Home</a>navbar.tsxa-navbar-home
<form>contact.vueform-contact-main

Where the LLM gets context:

  1. The id attribute
  2. The name attribute
  3. formControlName (Angular)
  4. Event handlers (@click, (click), onClick)
  5. The type attribute
  6. CSS classes
  7. Element content

Practical example

Before running Marker

html
<!-- hero.component.html -->
<section class="hero">
  <h1>Welcome to Our App</h1>
  <form class="signup-form">
    <input type="email" placeholder="Enter your email" formControlName="email">
    <input type="password" placeholder="Password" formControlName="password">
    <button type="submit" class="btn-primary">
      Get Started
    </button>
  </form>
  <a href="/login" class="link-secondary">Already have an account?</a>
</section>

Run Marker

bash
# Preview changes (nothing is modified)
python main.py add --project ./frontend --dry-run

# Output:
# [DRY-RUN] hero.component.html:
#   <input ... > → data-testid="input-hero-email"
#   <input ... > → data-testid="input-hero-password"  
#   <button ...> → data-testid="button-hero-submit"
#   <a ...> → data-testid="a-hero-login"

# Apply changes
python main.py add --project ./frontend

After running Marker

html
<!-- hero.component.html -->
<section class="hero">
  <h1>Welcome to Our App</h1>
  <form class="signup-form">
    <input type="email" placeholder="Enter your email" formControlName="email" data-testid="input-hero-email">
    <input type="password" placeholder="Password" formControlName="password" data-testid="input-hero-password">
    <button type="submit" class="btn-primary" data-testid="button-hero-submit">
      Get Started
    </button>
  </form>
  <a href="/login" class="link-secondary" data-testid="a-hero-login">Already have an account?</a>
</section>

Result: Four elements, four semantic test IDs, zero manual work.

Key benefits

1. Multi-framework support

Marker works with any modern frontend:

bash
# Angular
src/app/components/*.html
src/app/components/*.component.ts  # inline templates

# React
src/components/*.jsx
src/components/*.tsx

# Vue
src/components/*.vue  # SFC - extracts the <template> section

2. Local LLM = security

env
OLLAMA_MODEL=qwen3-coder:30b
OLLAMA_HOST=http://localhost:11434

Benefits of a local LLM:

  • ✅ Code does not leave your network
  • ✅ No API fees
  • ✅ Works offline
  • ✅ GDPR/compliance friendly
  • ✅ Qwen3-Coder specializes in code

3. Safety through backups

bash
# Marker automatically backs up files before changes
.marker_backup/
├── manifest.json           # Timestamp and list of files
├── hero.component.html     # Original
├── login.component.html    # Original
└── ...

# If something goes wrong, roll back
python main.py rollback --project ./frontend
# All changes are restored to their original state

4. Dry-run mode

bash
# Always preview first
python main.py add --project ./frontend --dry-run

# See exactly what will change:
# [DRY-RUN] Would modify 47 files
# [DRY-RUN] Would add 156 test IDs
# [DRY-RUN] Duplicates found: 0

5. Duplicate detection

bash
# Marker warns about conflicting IDs
⚠️  Duplicate test IDs detected:
  - button-submit: hero.component.html, contact.component.html
  - input-email: login.component.html, register.component.html

Integrations

Marker offers four ways to use it.

1. CLI (simplest)

bash
# Add test IDs
python main.py add --project /path/to/frontend

# Filter specific files
python main.py add --project /path --filter "login"

# Rollback
python main.py rollback --project /path

2. Python library

python
from ai_marker import AIMarker

marker = AIMarker()

# Process the project
result = marker.add_test_ids("/path/to/project")
print(f"Processed: {result.files_count} files")
print(f"Added: {result.ids_added} test IDs")

# Rollback
marker.rollback("/path/to/project")

3. gRPC server

bash
# Start the server
python grpc_server.py

# Call from any language
# Port: 50051
# Methods: RunMarker, PreviewChanges, Rollback, AnalyzeProject

4. MCP server (Claude integration)

json
// claude_desktop_config.json
{
  "mcpServers": {
    "marker": {
      "command": "python",
      "args": ["mcp_server.py"]
    }
  }
}

Then in Claude:

"Add data-testid to my Angular project at /home/user/frontend"
→ Claude calls the marker_run tool

Use cases

1. Legacy project migration

bash
# A project without tests needs test infrastructure
python main.py add --project ./legacy-app

# Result: 500 elements have data-testid
# The automation engineer can start writing tests

2. Preparing for E2E tests

bash
# Before integrating Cypress/Playwright
python main.py add --project ./frontend --dry-run
# Review generated IDs
python main.py add --project ./frontend

# Now in Cypress:
cy.get('[data-testid="button-hero-submit"]').click();

3. Component library

bash
# Shared components for the whole organization
python main.py add --project ./ui-library

# All components can be tested
# Consistent naming convention

4. CI/CD integration

yaml
# .github/workflows/marker.yml
- name: Check for missing test IDs
  run: |
    python main.py add --project ./frontend --dry-run
    # Fail if test IDs are missing

Architecture

┌─────────────────────────────────────────────────────┐
│                  User Interface                      │
│         CLI │ gRPC Server │ MCP Server              │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│              MarkerOrchestrator                      │
│   - Coordinates workflow                             │
│   - Tracks statistics                              │
│   - Aggregates results                               │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌───────────────┬──────────────────┬──────────────────┐
│FileAnalyzer   │TestIdGenerator   │  BackupManager   │
│               │                  │                  │
│ Scans       │ Regex detection   │ Backups           │
│ project       │ LLM generation  │ Rollback         │
│ Filters      │ Applies IDs      │ Manifest         │
└───────────────┴──────────────────┴──────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│                 Ollama + Qwen3-Coder                 │
│   - Local LLM inference                           │
│   - Semantic ID generation                       │
│   - Temperature: 0.1 (consistent results)        │
└─────────────────────────────────────────────────────┘

Quick start

bash
# 1. Install Ollama and the model
ollama pull qwen3-coder:30b

# 2. Configure .env
cat > .env << EOF
PROJECT_PATH=/path/to/frontend
OLLAMA_MODEL=qwen3-coder:30b
OLLAMA_HOST=http://localhost:11434
TARGET_ELEMENTS=button,input,select,a,form,textarea,table
SKIP_DIRECTORIES=node_modules,.git,dist,.angular,.nuxt
EOF

# 3. Preview changes
python main.py add --project /path/to/frontend --dry-run

# 4. Apply changes
python main.py add --project /path/to/frontend

# 5. (If needed) Rollback
python main.py rollback --project /path/to/frontend

Marker + Sentinel = a complete QA stack

Marker and Sentinel make a strong combination:

┌─────────────────────────────────────────────────────┐
│                    Marker                            │
│   Adds data-testid to all components         │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│                   Sentinel                           │
│   Generates test scenarios (JSON)              │
│   Uses data-testid selectors                 │
└──────────────────────┬──────────────────────────────┘
                       ↓
┌─────────────────────────────────────────────────────┐
│              Playwright / Cypress                    │
│   Runs automated tests                       │
└─────────────────────────────────────────────────────┘

Workflow:

  1. marker add → Every element has a stable selector
  2. sentinel analyze → JSON scenarios with data-testid selectors
  3. Test runner → Automated E2E tests

Conclusion

Marker turns tedious work into a one-time command:

Manual approachWith Marker
8–16 hours for 100 components5 minutes
Inconsistent namingSemantic convention
No backupAutomatic rollback
Copy-paste mistakesLLM-powered precision

When to use Marker:

  • ✅ A project needs test infrastructure
  • ✅ Moving to E2E testing with Cypress or Playwright
  • ✅ Migrating a legacy project
  • ✅ Standardizing a component library

Test IDs are not optional; they are a foundation of good testing. Marker adds them for you.


Marker is part of the QA automation toolchain alongside Sentinel. Both use local LLMs for secure processing of company code.

All articles