# ๐Ÿ“ md-e2e ### *The Zero-Glue-Code, Markdown-Native E2E Test Automation Framework powered by Playwright* [![Build Status](https://img.shields.io/badge/build-passing-34d399?style=for-the-badge&logo=github-actions&logoColor=white)](https://github.com/contributors/md-e2e/actions) [![PyPI Version](https://img.shields.io/badge/pypi-v0.4.0-38bdf8?style=for-the-badge&logo=pypi&logoColor=white)](https://pypi.org/project/md-e2e) [![Python Support](https://img.shields.io/badge/python-3.11%20%7C%203.12-fbbf24?style=for-the-badge&logo=python&logoColor=white)](https://pypi.org/project/md-e2e) [![Code Style: Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg?style=for-the-badge&logo=ruff)](https://github.com/astral-sh/ruff) [![Type Checked: Mypy](https://img.shields.io/badge/type%20checked-mypy-blue.svg?style=for-the-badge&logo=python)](https://github.com/python/mypy) [![License: MIT](https://img.shields.io/badge/License-MIT-a78bfa.svg?style=for-the-badge)](LICENSE)

Write plain Markdown. Execute production-grade Playwright tests. Zero boilerplate required.

Why md-e2e? โ€ข Architecture โ€ข Quick Start โ€ข DSL Reference โ€ข Variables & Matrix โ€ข Self-Healing โ€ข Custom Steps โ€ข Reports โ€ข Pytest โ€ข CLI

--- ## ๐Ÿ’ก Why md-e2e? **md-e2e** bridges the gap between technical and non-technical stakeholders. It empowers developers, QA engineers, and product managers to author, review, and execute high-resilience browser automation directly in readable Markdown files. | Feature / Metric | Cypress / Playwright | Cucumber / Behave | md-e2e | | :--- | :---: | :---: | :---: | | **Test Specification** | TypeScript / Python code | Gherkin `.feature` syntax | **Plain GitHub Markdown** | | **Glue Code Required** | โŒ None (direct code) | ๐Ÿ”ด Heavy (step definition files + regex) | ๐ŸŸข **Zero glue code needed** | | **Selector Resilience** | โš ๏ธ Manual selectors / test IDs | โš ๏ธ Rigid & brittle | ๐Ÿ›ก๏ธ **Multi-tier semantic locators** | | **Self-Healing** | โŒ None | โŒ None | ๐Ÿค– **Built-in AI & heuristic healing** | | **Collaborative Editing** | Engineers only | PMs write, engineers maintain | **Shared living documentation** | | **Setup Overhead** | Moderate to High | High (multiple dependencies) | **Single command (`pip install md-e2e`)** | ### Core Capabilities - ๐Ÿš€ **Zero Glue Code**: Human-readable actions resolve directly to Playwright locators without step-definition boilerplate. - ๐ŸŽฏ **Multi-Tier Semantic Locators**: Prioritizes accessible names and roles before falling back to titles, placeholders, or fuzzy text. - โšก **Compound Selector Support**: Seamlessly use Playwright engines (`data-testid=`, `xpath=`, `css=`), CSS classes (`#id`, `.class`), and compound chains (`div >> input[type="text"]`). - ๐Ÿ›ก๏ธ **Hybrid Self-Healing**: Resilient against UI refactors with 6 deterministic safeguards, assertion immunity, and DOM password redaction. - ๐Ÿ“Š **Data-Driven Matrix**: Run scenarios across Markdown tables with complete cross-row execution isolation. - ๐Ÿงฐ **Built-in Developer Tools**: Includes an interactive step-by-step debugger and codegen browser recorder. --- ## ๐Ÿ›๏ธ Architecture & Locator Engine md-e2e uses a multi-tier prioritized resolution model to locate DOM elements with high fidelity, preventing race conditions and fragile CSS selector failures.

md-e2e Architecture & Locator Engine

### Raw Selectors vs Natural Language md-e2e understands when an identifier is a technical CSS/Playwright selector versus natural language text: | Selector Pattern | Type | How md-e2e Resolves It | | :--- | :---: | :--- | | `button` / `#submit-btn` / `.btn-primary` | **CSS** | Direct CSS locator query | | `input[type="email"]` / `[disabled]` | **Attribute** | Direct CSS attribute locator query | | `div >> input[type="text"]` | **Chained** | Playwright compound selector chain | | `css=button.primary` / `xpath=//button` | **Engine** | Direct Playwright engine locator | | `data-testid="checkout-btn"` | **TestID** | Native `getByTestId` query | | `[Save]` / `[Cancel]` / `Next >> Page` | **Text** | **Natural Language**: Escaped & matched semantically | > [!NOTE] > Natural language phrases containing brackets or arrows (such as `[Save]` or `Click >> Next`) are safely treated as plain text and will never accidentally trigger raw selector syntax errors. --- ## ๐Ÿš€ Quick Start ### 1. Installation ```bash pip install md-e2e playwright install --with-deps chromium ``` ### 2. Initialize Project ```bash md-e2e init ``` This generates a standard test structure: ```text tests/ โ”œโ”€โ”€ sample.test.md # Starter Markdown test suite โ””โ”€โ”€ conftest.py # Custom step registrations & fixtures ``` ### 3. Write a Test (`tests/sample.test.md`) ```markdown # Sample E2E Test Suite ## Verify Example Domain - Navigate to "https://example.com" - Assert heading "Example Domain" is visible - Assert text "illustrative examples" is visible - Assert link "More information..." is visible ``` ### 4. Execute Tests ```bash # Standard headless run md-e2e run tests/ # Headed mode with 500ms action delay md-e2e run tests/ --headed --slowmo 500 # Execute on a specific browser engine (chromium, firefox, webkit) md-e2e run tests/ --browser firefox ``` --- ## ๐Ÿ“ Test Spec Anatomy A Markdown test file combines suite headings, tags, setup/teardown hooks, scenarios, and step lists: ````markdown # E-Commerce Suite @smoke @checkout ```python setup # Suite setup: runs once before all scenarios store.store("BASE_URL", "https://shop.example.com") ``` ## User Checkout @critical - Navigate to "{{BASE_URL}}/cart" - Fill input "Email" with "{{RANDOM_EMAIL}}" - Click button "Checkout" - Wait for URL contains "/confirmation" - Assert heading "Order Confirmed" is visible - Store text from heading "Order #" as "ORDER_ID" ```python teardown # Scenario teardown: runs after scenario (even on failure) print(f"Completed checkout order: {store.get('ORDER_ID')}") ``` ```` --- ## ๐Ÿ“– DSL Reference All step verbs are case-insensitive. Element targets and values can be enclosed in double quotes (`"`), single quotes (`'`), or backticks (`` ` ``). ### Navigation & Page Actions | Action | Example | | :--- | :--- | | `Navigate to ""` / `Go to ""` | `- Navigate to "https://example.com/login"` | | `Reload page` / `Reload` | `- Reload page` | ### Clicks & Mouse Actions | Action | Example | | :--- | :--- | | `Click button ""` | `- Click button "Sign In"` | | `Click link ""` | `- Click link "Forgot Password?"` | | `Click ""` | `- Click "Terms of Service"` | | `Click testid ""` | `- Click testid "theme-toggle-btn"` | | `Hover ""` / `Hover over ""` | `- Hover over "User Profile"` | | `Hover testid ""` | `- Hover testid "tooltip-trigger"` | ### Inputs & Forms | Action | Example | | :--- | :--- | | `Fill input "" with ""` | `- Fill input "Email" with "user@test.com"` | | `Fill "" with ""` | `- Fill "Password" with "Secret123!"` | | `Fill testid "" with ""` | `- Fill testid "search-box" with "laptop"` | | `Select "