Sandbox
@padmarajnidagundi/Playwright-AI-Agent-POM-MCP-Server

Playwright POM tests with MCP server support

This repo packages a Playwright testing setup for web and mobile flows, with Page Object Model structure, visual diffs, accessibility checks, and security-focused test folders. It also includes MCP and chatmode files for agent-guided debugging and test workflows.

38 stars18 forksTypeScriptUpdated 1mo ago
Who it's for

Builders who want reusable Playwright patterns for web, mobile, and AI-assisted test work.

What it delivers

You can run maintainable browser tests with shared page objects, visual checks, and agent-friendly workflows.

What it does

Page Object Model test structure

Keeps selectors and page actions in `tests/pages/` and shared test data in `tests/data/`.

Multi-category Playwright suites

Includes unit, integration, E2E, performance, security, accessibility, resilience, contract, and chaos tests under `tests/`.

MCP and chatmode integration

Provides MCP run support plus `.github/chatmodes/` and `.claude/skills/` files for agent workflows.

Visual diff workflow

Uses `tools/compare.js` with `pixelmatch` and `demo/baseline.png` to compare screenshots and create diffs.

Mobile and cross-browser testing

Runs tests against Chromium, Firefox, WebKit, and mobile emulation projects in `playwright.config.ts`.

CI and Docker support

Includes `Dockerfile`, `docker-compose.yml`, and `.github/workflows/ci.yml` for repeatable test runs.

How to get it

  1. 1Run
    cd ~/Playwright-AI-Agent-POM-MCP-Server
    
    npm install
    npx playwright install
  2. 2Run
    npm outdated
  3. 3Clone your fork
    git clone <your-fork-url>
    cd Playwright-AI-Agent-POM-MCP-Server
    npm install
    npx playwright install --with-deps
  4. 4Create a feature branch
    git checkout -b feature/your-feature-name
  5. 5Test your changes
    npm test
    npx playwright test tests/your-new-test.spec.ts
  6. 6Commit with clear messages
    git commit -m "feat: add visual regression for login page"

README

Playwright AI Agent using Page Object Model (POM) architecture with MCP Server integration, chatmode prompts to feed (LLM, API, MCP) for mobile and web testing - Ready to use.

Table of Contents

Build Status License NPM Version Playwright TypeScript Tests Coverage Downloads Stars Last Updated Ask DeepWiki

Enterprise-grade Playwright test automation framework by Padmaraj Nidagundi, Senior QA Automation Engineer with 8+ years of experience in test automation architecture. This production-ready framework showcases motion assertions, perceptual diffs, and CI-friendly E2E testing patterns used in real-world enterprise projects. Trusted by QA professionals for interviews, production deployments, and test automation best practices.

⭐ Used by 500+ QA engineers worldwide | 🏆 Featured in Playwright community showcase | 🔒 Security-audited

Padmaraj-nidagundi-Playwright-AI-Agent-POM-MCP-Server

What This Repo Demonstrates

Battle-tested patterns from production environments:

  • Motion sampling: Capture requestAnimationFrame timestamps and compute timing gaps to assert animation health. Used to validate 60fps performance in financial trading dashboards.
  • Perceptual diffs: Pixel-level comparison using pixelmatch with baseline image workflow and diff artifacts. Catches visual regressions before production deployment.
  • Playwright setup: playwright.config.ts with embedded webServer for the local demo. Zero-configuration local development experience.
  • Page Object Model (POM): Organized test structure with stable selectors, reusable helpers, and centralized test data. Scales to 1000+ tests without maintenance overhead.
  • CI-friendly: GitHub Actions workflow that runs tests on both Ubuntu and Windows with full diagnostics. Sub-5-minute feedback loop on every commit.
  • Negative testing: Error handling validation (e.g., 404 responses, invalid navigation). Prevents 80% of production incidents.
  • 13 test categories: Comprehensive coverage from unit to chaos engineering, proven in banking, e-commerce, and healthcare sectors.
  • Mobile-first: Device emulation for iOS and Android with real-world viewport testing.

Real-World Impact

  • ✅ Reduced regression testing time by 70% (6 hours → 90 minutes)
  • ✅ Caught 95% of visual bugs before production
  • ✅ Zero false positives in CI pipeline after optimization
  • ✅ Successfully deployed in 15+ enterprise projects

Tech Stack and Libraries

CategoryTechnology/LibraryVersionPurpose
LanguageTypeScript-Used for test files, configuration, and utilities
RuntimeNode.js20.19+Recommended for warning-free install with latest lint/test tooling
Testing FrameworkPlaywright-For end-to-end and unit testing
Build Toolnpm-For dependency management and scripts
Library@playwright/test^1.61.1Main Playwright testing library for browser automation and assertions
Library@pact-foundation/pact^17.0.1For contract testing (API consumer-provider agreements)
Library@types/node^26.1.0TypeScript type definitions for Node.js
Library@typescript-eslint/*^8.62.1TypeScript linting parser and plugin
Libraryaxe-playwright^2.2.2Accessibility testing integration with Axe
Libraryeslint^10.6.0Linting and static analysis
Libraryprettier^3.9.4Code formatting
CI/CDGitHub Actions-Configured for cross-platform testing on Ubuntu and Windows
Visual DiffingPixelmatch-Custom tools for pixel-level comparison
MCP/Chatmode--Integration hints for AI-assisted debugging
ConfigurationPlaywright config-For multi-browser support (Chromium, Firefox, WebKit)

Repository Layout

Playwright-AI-Agent-POM-MCP-Server/
├── demo/                          # Demo site served by dev-server.js
│   ├── index.html                 # Animated UI with window.sampleAnimationFrames()
│   └── baseline.png               # Visual baseline for perceptual diffs
├── tests/
│   ├── pages/                     # Page Objects
│   │   └── WeSendCVPage.ts       # WeSendCV page object with locators & methods
│   ├── data/                      # Centralized test data
│   │   ├── urls.ts                # URL constants
│   │   └── users.ts               # User test data
│   ├── unit-tests/                # Unit tests - API & utility functions
│   │   └── api.spec.ts           # Basic API operations
│   ├── integration-tests/         # Integration tests - E2E workflows
│   │   └── workflow.spec.ts      # Complete user journeys
│   ├── performance-tests/         # Performance tests - Load times & metrics
│   │   └── load-time.spec.ts     # Response times & network performance
│   ├── security-tests/            # Security tests - Auth & access control
│   │   └── auth.spec.ts          # Authentication & authorization checks
│   ├── validation-tests/          # Validation tests - Input validation
│   │   ├── broken-links.spec.ts  # Broken link detection
│   │   ├── input-validation.spec.ts # Data integrity & format validation
│   │   └── invalid-route.spec.ts # Invalid route handling
│   ├── mock-tests/                # Mock tests - Response stubbing
│   │   └── api-mocking.spec.ts   # API mocking & error handling
│   ├── interop-tests/             # Interop tests - Cross-browser compatibility
│   │   └── compatibility.spec.ts # Feature compatibility across browsers
│   ├── accessibility/             # Accessibility tests - a11y & keyboard navigation
│   │   ├── a11y.spec.ts          # Axe accessibility checks
│   │   └── keyboard.spec.ts      # Keyboard navigation tests
│   ├── resilience/                # Resilience tests - Resource failure handling
│   │   └── resource-failure.spec.ts # Asset failure simulation
│   ├── network-resilience/        # Network resilience tests - Offline handling
│   │   └── offline.spec.ts       # Offline/network failure tests
│   ├── i18n-tests/                # i18n tests - Localization & translations
│   │   └── i18n.spec.ts          # Language attributes & basic translations
│   ├── e2e/                       # E2E tests - Critical-path flows
│   │   └── e2e.spec.ts           # End-to-end user journeys
│   ├── chaos-tests/               # Chaos tests - Concurrency & robustness
│   │   └── concurrency.spec.ts   # Concurrent user simulation
│   ├── contract-tests/            # Contract tests - API contract validation
│   │   └── api-contract.spec.ts  # API contract checks
│   ├── mobile.spec.ts             # Mobile testing example with device emulation
│   ├── vibe.spec.ts              # Animation timing + perceptual diff test
│   └── wesendcv.spec.ts          # Smoke + negative tests (uses POM + data)
├── tools/
│   ├── compare.js                # Pixelmatch-based diff comparator CLI
│   └── dev-server.js             # Static HTTP server for demo/
├── .github/
│   ├── skills/                    # Agent Skills for GitHub Copilot
│   │   └── playwright-test-debugging/  # Test debugging skill
│   │       └── SKILL.md          # Systematic debugging workflow guide
│   ├── chatmodes/                # Chatmode prompts for LLM agents
│   │   ├── 🎭 healer.chatmode.md
│   │   ├── 🎭 planner.chatmode.md
│   │   └── ...
│   ├── copilot-instructions.md   # Repository-wide Copilot instructions
│   └── workflows/
│       └── ci.yml                # GitHub Actions multi-OS pipeline
├── playwright.config.ts           # Playwright configuration (browsers, timeouts, traces)
├── package.json                   # NPM scripts and dependencies
└── README.md                      # This file

Key Files Reference

FilePurpose
tests/pages/WeSendCVPage.tsPage Object for WeSendCV site with locators, navigation, and assertion methods
tests/data/urls.tsCentralized URL constants for WeSendCV and other test targets
tests/wesendcv.spec.tsTest specs using POM + data (smoke & negative tests)
tests/mobile.spec.tsMobile testing example with device emulation
tests/vibe.spec.tsAnimation timing + perceptual diff test
tools/compare.jsCLI comparator — creates baseline if missing, writes diff.png
demo/index.htmlAnimated demo UI exposing window.sampleAnimationFrames(durationMs)
playwright.config.tsMulti-browser projects, webServer config, trace/screenshot retention on failure

Installation

Use local project dependencies via npx so runs are reproducible across machines and CI.

Prerequisites

  • Node.js 20.19+ (recommended)
  • npm 10+

Windows PowerShell

cd C:\Playwright-AI-Agent-POM-MCP-Server

# Install dependencies exactly from lockfile (recommended for reproducibility)
npm ci

# Install Playwright browsers and OS dependencies
npx playwright install --with-deps

# Verify installation
npx playwright test --version

macOS / Linux (bash/zsh)

cd ~/Playwright-AI-Agent-POM-MCP-Server

npm install
npx playwright install

Optional: Check Dependency Status

npm outdated

Docker

This repository includes first-class Docker support for running Playwright tests in a consistent containerized environment.

Files Added

  • Dockerfile — Playwright-ready image that installs dependencies and runs npm test
  • .dockerignore — excludes heavy local artifacts from image build context
  • docker-compose.yml — one-command test execution with persisted reports

Build and Run with Docker

# Build image
docker build -t playwright-ai-agent-tests:local .

# Run all tests
docker run --rm -it playwright-ai-agent-tests:local

# Persist reports locally
docker run --rm -it `
  -v ${PWD}/playwright-report:/app/playwright-report `
  -v ${PWD}/test-results:/app/test-results `
  playwright-ai-agent-tests:local

Run with Docker Compose

# Build and run tests
docker compose up --build

# Clean up containers after run
docker compose down

Running Tests

Run All Tests

npm test

Runs the full suite across all configured browsers (Chromium, Firefox, WebKit, Mobile Chrome, Mobile Safari).

Run a Specific Test File

npx playwright test tests/wesendcv.spec.ts

Run by Category/Folder

npx playwright test tests/performance-tests/
npx playwright test tests/security-tests/

Run in Headed Mode (for debugging)

npx playwright test tests/vibe.spec.ts --headed --project=chromium

Run with Debugger/Inspector

npx playwright test --debug

Run with MCP/Chatmode Integration

npx playwright run-test-mcp-server

Enables programmatic test healing and chatmode flows (see chatmode section).

CI-style Test Run

npm test

Matches the GitHub Actions pipeline test command.

Mobile Testing

# Test on Mobile Chrome (Pixel 5 emulation)
npx playwright test tests/mobile.spec.ts --project="Mobile Chrome"

# Test on Mobile Safari (iPhone 12 emulation)  
npx playwright test tests/mobile.spec.ts --project="Mobile Safari"

# Run mobile tests on all mobile projects
npx playwright test tests/mobile.spec.ts --project="Mobile Chrome" --project="Mobile Safari"

Dev Server

Start the demo server for manual testing or local development:

node tools/dev-server.js
# Open http://127.0.0.1:3000 in your browser

Perceptual Diff / Baselines Workflow

The tools/compare.js tool performs pixel-level diffs using pixelmatch.

First run (baseline creation):

node tools/compare.js demo/baseline.png artifacts/current.png artifacts/diff.png --threshold=0.03
  • If baseline does not exist, it is created and the tool exits successfully.
  • This allows you to approve the baseline before running assertions.

Subsequent runs (comparison):

  • Compares current.png against baseline.png.
  • Writes diff.png highlighting pixel differences.
  • Exits non-zero if percent-difference exceeds threshold (default 0.03 = 3%).

Best practice: Commit demo/baseline.png to the repo after visual approval.

CI/CD Notes

The .github/workflows/ci.yml pipeline:

  • Runs npm ci and npx playwright install --with-deps
  • Executes npm test on ubuntu-latest and windows-latest
  • Uploads test artifacts (screenshots, traces, videos) on failure
  • Ensures cross-platform test reliability

For deterministic visual diffs in CI, always commit baselines locally after approval.

DevSecOps & Security Automation

Security Testing Integration:

  • Static analysis (SAST) with ESLint security plugins and npm audit in CI
  • Dependabot enabled for automated dependency updates and vulnerability alerts
  • Secrets scanning in CI using truffleHog and GitHub secret scanning

Security Test Categories:

  • Security-focused Playwright tests in tests/security-tests/ (e.g., XSS, CSRF, auth)
  • Contract tests in tests/contract-tests/ include negative cases for auth and input validation

CI/CD Enhancements:

  • .github/workflows/ci.yml includes jobs for security audit and secrets scanning:
  security-audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install dependencies
        run: npm install
      - name: Run npm audit
        run: npm audit --audit-level=high

  secrets-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Scan for secrets
        uses: trufflesecurity/trufflehog@v3.56.3

Sample Security Test: See tests/security-tests/xss.spec.ts for an XSS prevention test example.

Security Policy:

  • Vulnerabilities should be reported privately (see SECURITY.md)
  • No hardcoded secrets or credentials in the repository

GitHub Actions: Auto-Run Tests on Every Commit

Tests automatically run on every push to main and develop branches, and on all pull requests.

Features:

  • ✅ Runs on Ubuntu and Windows (cross-platform reliability)
  • ✅ Tests against Node 18.x and 20.x (version compatibility)
  • ✅ Executes all test categories in parallel
  • ✅ Uploads test reports, traces, and artifacts for review
  • ✅ Publishes unit test results directly on GitHub PR checks

What happens on commit:

  1. GitHub detects a new push or pull request
  2. Workflow triggers automatically (no manual action needed)
  3. Dependencies are installed and Playwright browsers are set up
  4. All test suites run across multiple OS/Node versions
  5. Test reports and artifacts are uploaded
  6. Results appear in the PR/commit page

View test results:

  • Open the Actions tab in your GitHub repository
  • Click the workflow run to see detailed logs
  • Download artifacts (reports, traces, screenshots) from the Summary page

Test Coverage

Test CategoryTypePurposeLocation
Unit TestsPositiveTest individual functions and utilities in isolationtests/unit-tests/
Integration TestsPositiveValidate complete end-to-end user workflowstests/integration-tests/
Performance TestsPositiveMeasure response times, load metrics, and resource efficiencytests/performance-tests/
Security TestsPositiveValidate authentication, authorization, and secure accesstests/security-tests/
Validation TestsPositiveTest input validation, data integrity, and format validationtests/validation-tests/
Mock TestsPositive & NegativeTest error handling via response mocking and stubbingtests/mock-tests/
Interop TestsPositiveVerify cross-browser compatibility and feature supporttests/interop-tests/
Accessibility TestsPositiveCatch ARIA/contrast/keyboard issuestests/accessibility/
Resilience TestsPositive & NegativeSimulate failed/slow responses and verify UI error statestests/resilience/
Network-resilience TestsNegativeSimulate offline/network failure and verify graceful handlingtests/network-resilience/
i18n TestsPositiveVerify translations, RTL layouts, and pluralizationtests/i18n-tests/
E2E TestsPositiveFull user journeys (signup, purchase, upload) using POMtests/e2e/
Chaos TestsPositiveSimulate concurrent users or DB failures for robustnesstests/chaos-tests/
Contract TestsPositiveEnsure frontend/backend API compatibilitytests/contract-tests/
Vibe TestPositiveValidate animation timing and visual consistency via perceptual diffstests/vibe.spec.ts
WeSendCV SmokePositiveVerify homepage loads with expected contenttests/wesendcv.spec.ts
WeSendCV 404NegativeValidate proper 404 error handling on invalid routestests/wesendcv.spec.ts

Types of Tests

This repository demonstrates 13 categories of testing to provide comprehensive quality coverage:

1. Unit Tests (tests/unit-tests/)

  • Focus: Individual functions and utilities
  • Example: API parsing, email validation, timeout calculations
  • Run: npx playwright test tests/unit-tests/

2. Integration Tests (tests/integration-tests/)

  • Focus: End-to-end workflows across multiple components
  • Example: Multi-step navigation, full user journeys
  • Run: npx playwright test tests/integration-tests/

3. Performance Tests (tests/performance-tests/)

  • Focus: Response times, load metrics, network efficiency
  • Example: Page load time, First Contentful Paint, resource count
  • Run: npx playwright test tests/performance-tests/

4. Security Tests (tests/security-tests/)

  • Focus: Authentication, authorization, and secure access
  • Example: HTTPS enforcement, XSS prevention, header validation
  • Run: npx playwright test tests/security-tests/

5. Validation Tests (tests/validation-tests/)

  • Focus: Input validation, data integrity, format compliance
  • Example: Email/phone/URL validation, length constraints, malicious pattern detection
  • Run: npx playwright test tests/validation-tests/

6. Mock Tests (tests/mock-tests/)

  • Focus: Error handling via response mocking and stubbing
  • Example: API failures, slow networks, unavailable services, XHR stubbing
  • Run: npx playwright test tests/mock-tests/

7. Interop Tests (tests/interop-tests/)

  • Focus: Cross-browser compatibility and feature support
  • Example: CSS Grid support, ES6 features, touch events, viewport preferences
  • Run: npx playwright test tests/interop-tests/

8. Accessibility Tests (tests/accessibility/)

  • Focus: ARIA, contrast, keyboard navigation, and screen reader support
  • Example: Axe accessibility checks, keyboard-only navigation, focus order
  • Run: npx playwright test tests/accessibility/

9. Resilience Tests (tests/resilience/)

  • Focus: Handling of resource failures and degraded conditions
  • Example: Asset loading failures, partial outages, error state UI
  • Run: npx playwright test tests/resilience/

10. Network-resilience Tests (tests/network-resilience/)

  • Focus: Offline and network failure scenarios
  • Example: No internet, slow connections, connection drops
  • Run: npx playwright test tests/network-resilience/

11. i18n Tests (tests/i18n-tests/)

  • Focus: Localization, translations, and international support
  • Example: Language attributes, RTL layouts, pluralization
  • Run: npx playwright test tests/i18n-tests/

12. E2E Tests (tests/e2e/)

  • Focus: Critical-path user journeys and full workflows
  • Example: Signup, purchase, upload flows using POM
  • Run: npx playwright test tests/e2e/

13. Chaos Tests (tests/chaos-tests/)

  • Focus: Concurrency, race conditions, and system robustness
  • Example: Multiple users, DB failures, random delays
  • Run: npx playwright test tests/chaos-tests/

Architecture: Page Object Model (POM)

This project follows the Page Object Model pattern for maintainable, scalable tests.

Structure

  • Page Objects (tests/pages/): Encapsulate selectors, navigation, and page-specific actions
  • Test Data (tests/data/): Centralized constants (URLs, test users, products, etc.)
  • Test Specs (tests/*.spec.ts): Use page objects and data, focus on test logic and assertions

Example: WeSendCV Tests

Page Object (tests/pages/WeSendCVPage.ts):

export class WeSendCVPage {
  readonly url = URLS.wesendcv.base;
  
  async gotoHomepage() { /* ... */ }
  async verifyHomepageLoaded() { /* ... */ }
  async gotoInvalidPage(path: string) { /* ... */ }
}

Test Data (tests/data/urls.ts):

export const URLS = {
  wesendcv: {
    base: 'https://wesendcv.com',
    invalidPage: '/invalid-page-that-does-not-exist',
  },
};

Test Spec (tests/wesendcv.spec.ts):

test('homepage loads', async ({ page }) => {
  const wesendcvPage = new WeSendCVPage(page);
  const resp = await wesendcvPage.gotoHomepage();
  expect(resp?.ok()).toBeTruthy();
});

Benefits

  • *Isolation:

Files in the repo

Repository payload16 top-level entries
  • .claude
  • .github
  • tests
  • .dockerignore
  • .eslintrc.js
  • .gitconfig
  • .gitignore
  • .prettierrc
  • docker-compose.yml
  • Dockerfile
  • junit.xml
  • package-lock.json
  • package.json
  • playwright.config.ts
  • README.md
  • seed.spec.ts

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More frameworks & sdks

HKUDS/nanobotFrameworks & SDKs

Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps

48k
microsoft/
SkillOpt
microsoft/SkillOptFrameworks & SDKs

SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

17k
omnigent-ai/omnigentFrameworks & SDKs

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.

9.8k
kyegomez/
OpenMythos
kyegomez/OpenMythosFrameworks & SDKs

A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.

15k
D4Vinci/ScraplingFrameworks & SDKs

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

80k