Mimic

AI-powered browser testing framework that converts Gherkin or plain language tests into executable code, with self-repair capabilities when tests break due to code changes.

Mimic learns how your app works, remembers what succeeds, repeats it reliably — and only thinks again when something breaks.

Overview

Mimic (playwright-mimic) is an AI-powered browser testing framework that revolutionizes how we write and maintain browser tests. Instead of writing brittle, selector-dependent test code, you write tests in plain English or Gherkin syntax, and Mimic converts them into executable Playwright code.

When your application changes and tests break, Mimic doesn't just fail — it reasons about what changed, repairs the test, and saves a new verified recording.

Key Features

  • 🤖
    AI-Powered Conversion: Uses language models to understand and execute natural language test instructions
  • 🎯
    Smart Element Selection: Automatically finds and interacts with elements based on semantic understanding
  • 📝
    Gherkin-Style Syntax: Write tests in natural language, one instruction per line
  • 🔄
    Self-Repair Capability: Automatically repairs broken tests when application code changes
  • 🎭
    Playwright Integration: Built on top of Playwright for reliable browser automation
  • 📊
    Token Tracking: Built-in token usage tracking for AI model calls
  • 💾
    Snapshot Storage: Automatically saves and replays successful test executions
  • 🎯
    Best Selector System: Stores optimal selectors (role, label, testid) for reliable element identification

How It Works

Learn → Remember → Repeat → Troubleshoot & Fix

1. Learn — Understand the Intent

  • Dynamically injects marker code to assign data-mimic-id attributes to elements
  • Interprets your intent and reasons about the page
  • Identifies the most likely elements to interact with
  • Generates executable Playwright steps

This happens automatically and requires no changes to your application code.

2. Remember — Capture a Verified Recording

  • Resolved interaction steps with full action details
  • Best selector descriptors (role, label, testid, etc.)
  • Mimic IDs from injected markers
  • Execution metadata and timestamps

Snapshots are stored in <testname>.mimic.json files alongside your tests.

3. Repeat — Fast, Deterministic Execution

  • Loads the snapshot from disk
  • Reconstructs locators from stored selector descriptors
  • Re-injects markers for troubleshooting if needed
  • Executes actions directly without AI

4. Troubleshoot & Fix — Adapt When Things Change

  • Analyzes what failed and why
  • Re-learns the updated application
  • Selectively regenerates only broken steps
  • Saves a new verified snapshot

Element Identification System

  • Dynamic marker injection using data-mimic-id
  • Best selector generation using Playwright semantic locators
  • Snapshot storage of SelectorDescriptor objects
  • Prefers role, label, testid, text before CSS or XPath

This ensures tests remain stable even when DOM structure changes, without requiring any application code changes.

Features

  • AI integration to work out what is needed
  • AI detection of correct component(s) and actions from text
  • Enacting those actions in order
  • Logging token use
  • Snapshotting passing tests
  • Best selector storage (role, label, testid)
  • Dynamically watching page while page is loading (SPA)