Contents
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:
// ❌ 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:
<!-- 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 teamThe solution: Marker, an AI-powered test ID generator
Marker is a Python tool that:
- Scans your Angular, React or Vue frontend project
- Identifies elements without data-testid
- Uses a local LLM to generate semantic IDs
- Applies changes to files, with rollback support
# One run = the whole project
python main.py add --project /path/to/frontend
# Result: all interactive elements have data-testidHow 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-testidWhich elements does Marker process?
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:
| Element | Context | Generated ID |
|---|---|---|
<button>Submit</button> | hero.component.html | button-hero-submit |
<input type="email"> | login.component.html | input-login-email |
<a href="/">Home</a> | navbar.tsx | a-navbar-home |
<form> | contact.vue | form-contact-main |
Where the LLM gets context:
- The
idattribute - The
nameattribute formControlName(Angular)- Event handlers (
@click,(click),onClick) - The
typeattribute - CSS classes
- Element content
Practical example
Before running Marker
<!-- 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
# 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 ./frontendAfter running Marker
<!-- 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:
# 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> section2. Local LLM = security
OLLAMA_MODEL=qwen3-coder:30b
OLLAMA_HOST=http://localhost:11434Benefits 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
# 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 state4. Dry-run mode
# 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: 05. Duplicate detection
# Marker warns about conflicting IDs
⚠️ Duplicate test IDs detected:
- button-submit: hero.component.html, contact.component.html
- input-email: login.component.html, register.component.htmlIntegrations
Marker offers four ways to use it.
1. CLI (simplest)
# 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 /path2. Python library
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
# Start the server
python grpc_server.py
# Call from any language
# Port: 50051
# Methods: RunMarker, PreviewChanges, Rollback, AnalyzeProject4. MCP server (Claude integration)
// 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 toolUse cases
1. Legacy project migration
# 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 tests2. Preparing for E2E tests
# 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
# Shared components for the whole organization
python main.py add --project ./ui-library
# All components can be tested
# Consistent naming convention4. CI/CD integration
# .github/workflows/marker.yml
- name: Check for missing test IDs
run: |
python main.py add --project ./frontend --dry-run
# Fail if test IDs are missingArchitecture
┌─────────────────────────────────────────────────────┐
│ 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
# 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/frontendMarker + 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:
marker add→ Every element has a stable selectorsentinel analyze→ JSON scenarios with data-testid selectors- Test runner → Automated E2E tests
Conclusion
Marker turns tedious work into a one-time command:
| Manual approach | With Marker |
|---|---|
| 8–16 hours for 100 components | 5 minutes |
| Inconsistent naming | Semantic convention |
| No backup | Automatic rollback |
| Copy-paste mistakes | LLM-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.