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.
- What This Repo Demonstrates
- Repository Layout
- Key Files Reference
- Installation
- Docker
- Running Tests
- Mobile Testing
- Dev Server
- Perceptual Diff / Baselines Workflow
- CI/CD Notes
- Test Coverage
- Types of Tests
- Architecture: Page Object Model (POM)
- AI Agents â Chatmodes & Skills
- Best Practices & Tips
- How to Extend
- Common Commands
- Troubleshooting
- License & Attribution
- Contact
- Questions or feedback?
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
Battle-tested patterns from production environments:
- Motion sampling: Capture
requestAnimationFrametimestamps and compute timing gaps to assert animation health. Used to validate 60fps performance in financial trading dashboards. - Perceptual diffs: Pixel-level comparison using
pixelmatchwith baseline image workflow and diff artifacts. Catches visual regressions before production deployment. - Playwright setup:
playwright.config.tswith embeddedwebServerfor 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.
- â 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
| Category | Technology/Library | Version | Purpose |
|---|---|---|---|
| Language | TypeScript | - | Used for test files, configuration, and utilities |
| Runtime | Node.js | 18.x or 20.x | As specified in CI |
| Testing Framework | Playwright | - | For end-to-end and unit testing |
| Build Tool | npm | - | For dependency management and scripts |
| Library | @playwright/test | ^1.35.0 | Main Playwright testing library for browser automation and assertions |
| Library | @pact-foundation/pact | ^16.0.2 | For contract testing (API consumer-provider agreements) |
| Library | @types/node | ^24.10.1 | TypeScript type definitions for Node.js |
| Library | axe-playwright | ^2.2.2 | Accessibility testing integration with Axe |
| CI/CD | GitHub Actions | - | Configured for cross-platform testing on Ubuntu and Windows |
| Visual Diffing | Pixelmatch | - | Custom tools for pixel-level comparison |
| MCP/Chatmode | - | - | Integration hints for AI-assisted debugging |
| Configuration | Playwright config | - | For multi-browser support (Chromium, Firefox, WebKit) |
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
| File | Purpose |
|---|---|
tests/pages/WeSendCVPage.ts |
Page Object for WeSendCV site with locators, navigation, and assertion methods |
tests/data/urls.ts |
Centralized URL constants for WeSendCV and other test targets |
tests/wesendcv.spec.ts |
Test specs using POM + data (smoke & negative tests) |
tests/mobile.spec.ts |
Mobile testing example with device emulation |
tests/vibe.spec.ts |
Animation timing + perceptual diff test |
tools/compare.js |
CLI comparator â creates baseline if missing, writes diff.png |
demo/index.html |
Animated demo UI exposing window.sampleAnimationFrames(durationMs) |
playwright.config.ts |
Multi-browser projects, webServer config, trace/screenshot retention on failure |
This repository supports advanced automation and skill-based workflows using the Playwright CLI. The CLI can be used for browser automation, test debugging, and loading custom skills for Copilot or agent workflows.
It is recommended to install the official Playwright CLI globally:
npm install -g @playwright/cliYou can use the CLI for browser automation, page interaction, and more:
# Open a browser
playwright open https://example.com
# Take a screenshot
playwright screenshot page.png
# Run a test
playwright test tests/wesendcv.spec.tsTo enable Copilot or agent workflows with repository-specific skills, use the following command:
playwright install --skillsThis will load all skills found in .github/skills/ and make them available for Copilot and agent-based debugging or automation. For more information on skills, see the Agent Skills section below.
Note: If you see a deprecation warning for
playwright-cli, always prefer@playwright/clifor the latest features and compatibility.
cd C:\Playwright-AI-Agent-POM-MCP-Server
# Install dependencies
npm install
# Install Playwright browsers
npx playwright install --with-deps
# Verify installation
npx playwright test --versioncd ~/Playwright-AI-Agent-POM-MCP-Server
npm install
npx playwright installThis repository includes first-class Docker support for running Playwright tests in a consistent containerized environment.
Dockerfileâ Playwright-ready image that installs dependencies and runsnpm test.dockerignoreâ excludes heavy local artifacts from image build contextdocker-compose.ymlâ one-command test execution with persisted reports
# 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# Build and run tests
docker compose up --build
# Clean up containers after run
docker compose downnpm testRuns the full suite across all configured browsers (Chromium, Firefox, WebKit, Mobile Chrome, Mobile Safari).
npx playwright test tests/wesendcv.spec.tsnpx playwright test tests/performance-tests/
npx playwright test tests/security-tests/npx playwright test tests/vibe.spec.ts --headed --project=chromiumnpx playwright test --debugnpx playwright run-test-mcp-serverEnables programmatic test healing and chatmode flows (see chatmode section).
npm run test:ciMatches the GitHub Actions pipeline configuration.
# 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"Start the demo server for manual testing or local development:
node tools/dev-server.js
# Open http://127.0.0.1:3000 in your browserThe 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.pngagainstbaseline.png. - Writes
diff.pnghighlighting 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.
The .github/workflows/ci.yml pipeline:
- Runs
npm ciandnpx playwright install --with-deps - Executes
npm run test:cionubuntu-latestandwindows-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.
Security Testing Integration:
- Static analysis (SAST) with ESLint security plugins and
npm auditin 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.ymlincludes 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.3Sample 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
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:
- GitHub detects a new push or pull request
- Workflow triggers automatically (no manual action needed)
- Dependencies are installed and Playwright browsers are set up
- All test suites run across multiple OS/Node versions
- Test reports and artifacts are uploaded
- 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 Category | Type | Purpose | Location |
|---|---|---|---|
| Unit Tests | Positive | Test individual functions and utilities in isolation | tests/unit-tests/ |
| Integration Tests | Positive | Validate complete end-to-end user workflows | tests/integration-tests/ |
| Performance Tests | Positive | Measure response times, load metrics, and resource efficiency | tests/performance-tests/ |
| Security Tests | Positive | Validate authentication, authorization, and secure access | tests/security-tests/ |
| Validation Tests | Positive | Test input validation, data integrity, and format validation | tests/validation-tests/ |
| Mock Tests | Positive & Negative | Test error handling via response mocking and stubbing | tests/mock-tests/ |
| Interop Tests | Positive | Verify cross-browser compatibility and feature support | tests/interop-tests/ |
| Accessibility Tests | Positive | Catch ARIA/contrast/keyboard issues | tests/accessibility/ |
| Resilience Tests | Positive & Negative | Simulate failed/slow responses and verify UI error states | tests/resilience/ |
| Network-resilience Tests | Negative | Simulate offline/network failure and verify graceful handling | tests/network-resilience/ |
| i18n Tests | Positive | Verify translations, RTL layouts, and pluralization | tests/i18n-tests/ |
| E2E Tests | Positive | Full user journeys (signup, purchase, upload) using POM | tests/e2e/ |
| Chaos Tests | Positive | Simulate concurrent users or DB failures for robustness | tests/chaos-tests/ |
| Contract Tests | Positive | Ensure frontend/backend API compatibility | tests/contract-tests/ |
| Vibe Test | Positive | Validate animation timing and visual consistency via perceptual diffs | tests/vibe.spec.ts |
| WeSendCV Smoke | Positive | Verify homepage loads with expected content | tests/wesendcv.spec.ts |
| WeSendCV 404 | Negative | Validate proper 404 error handling on invalid routes | tests/wesendcv.spec.ts |
This repository demonstrates 13 categories of testing to provide comprehensive quality coverage:
- Focus: Individual functions and utilities
- Example: API parsing, email validation, timeout calculations
- Run:
npx playwright test tests/unit-tests/
- Focus: End-to-end workflows across multiple components
- Example: Multi-step navigation, full user journeys
- Run:
npx playwright test tests/integration-tests/
- Focus: Response times, load metrics, network efficiency
- Example: Page load time, First Contentful Paint, resource count
- Run:
npx playwright test tests/performance-tests/
- Focus: Authentication, authorization, and secure access
- Example: HTTPS enforcement, XSS prevention, header validation
- Run:
npx playwright test tests/security-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/
- Focus: Error handling via response mocking and stubbing
- Example: API failures, slow networks, unavailable services, XHR stubbing
- Run:
npx playwright test tests/mock-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/
- Focus: ARIA, contrast, keyboard navigation, and screen reader support
- Example: Axe accessibility checks, keyboard-only navigation, focus order
- Run:
npx playwright test tests/accessibility/
- Focus: Handling of resource failures and degraded conditions
- Example: Asset loading failures, partial outages, error state UI
- Run:
npx playwright test tests/resilience/
- Focus: Offline and network failure scenarios
- Example: No internet, slow connections, connection drops
- Run:
npx playwright test tests/network-resilience/
- Focus: Localization, translations, and international support
- Example: Language attributes, RTL layouts, pluralization
- Run:
npx playwright test tests/i18n-tests/
- Focus: Critical-path user journeys and full workflows
- Example: Signup, purchase, upload flows using POM
- Run:
npx playwright test tests/e2e/
- Focus: Concurrency, race conditions, and system robustness
- Example: Multiple users, DB failures, random delays
- Run:
npx playwright test tests/chaos-tests/
This project follows the Page Object Model pattern for maintainable, scalable tests.
- 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
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();
});- Isolation: Tests don't know about selectors or implementation details
- Reusability: Page methods shared across multiple test specs
- Maintainability: Update selectors in one place, all tests benefit
- Scalability: Easy to add new page objects and test data as the suite grows
This repository ships with six AI agent chatmodes and two agent skills that power GitHub Copilot, VS Code agent mode, and any MCP-compatible LLM to automate test planning, generation, debugging, code review, and manual testing guidance.
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| main@2026-05-27 | Latest activity on main branch | High | 5/27/2026 |
| 0.0.0 | No release found â using repo HEAD | High | 4/21/2026 |
| main@2026-04-21 | Latest activity on main branch | High | 4/21/2026 |
