Playwright C# Agentic Framework

A production-ready C# test automation framework that combines Playwright's powerful browser automation with intelligent healing agents. Write maintainable tests using SpecFlow (Gherkin), leverage Page Object Model patterns, and let AI agents automatically repair broken selectors when your application changes.

View on GitHub

Overview

The Playwright C# Agentic Framework is designed for teams that need reliable, self-healing test automation. It integrates:

  • Playwright – Fast, reliable browser automation
  • SpecFlow – Readable Gherkin scenarios with NUnit runner
  • Page Object Model (POM) – Maintainable selector management
  • Healing Agents – Automatic selector repair when tests break

Key Features

🎭 Planner Agent

Explores your application and produces a comprehensive Markdown test plan. Use it to generate structured test strategies before writing scenarios.

🎭 Generator Agent

Transforms test plans into executable SpecFlow feature files and step definitions. Accelerate test creation with AI-generated scenarios.

🎭 Healer Agent

The core innovation: automatically detects selector failures and repairs Page Objects without manual intervention. When your application's DOM changes, the Healer updates your tests automatically.

How Healing Works

The framework uses a three-phase approach to maintain test reliability:

  1. Learn Phase: During green test runs, the framework records multiple locator strategies per element (data-test attributes, role+name combinations, CSS selectors) into a registry.
  2. Failure Detection: When a selector breaks, the Healer parses failing pages from test output to identify the exact failure point.
  3. Auto-Repair: Using the selector registry and Roslyn code analysis, the Healer rewrites failing Page Object properties to use known-good strategies, rebuilds the project, and re-runs tests.
Result
Your tests self-heal without hand-coded fallback rules or manual selector updates.

Quick Start

dotnet restore
dotnet build
dotnet build ./Tests.E2E/Tests.E2E.csproj bash ./Tests.E2E/bin/Debug/net9.0/playwright.sh install --with-deps chromium
dotnet test ./Tests.E2E/Tests.E2E.csproj

Project Structure

Framework/          # Core test framework (POM, config, selectors)
Agents/             # Planner / Generator / Healer console app
Tests.E2E/          # SpecFlow features, steps, hooks, appsettings, NUnit
agents/             # Output folder for plans and selectors.registry.json
artifacts/          # (optional) traces/videos on failures

Requirements

  • .NET SDK 9.0+
  • Playwright browsers (installed per project)
  • Allure CLI (for reporting) – brew install allure on macOS

Next Steps

Why This Framework?

Traditional test automation requires constant maintenance when applications change. Selectors break, tests fail, and developers spend hours updating Page Objects. The Playwright C# Agentic Framework eliminates this burden by:

  • Recording multiple selector strategies during successful runs
  • Automatically detecting when selectors fail
  • Self-repairing Page Objects using known-good alternatives
  • Rebuilding and re-running tests without manual intervention

Focus on writing test scenarios, not fixing broken selectors.