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 |
|---|---|---|---|
| 0.0.0 | No release found β using repo HEAD | High | 4/21/2026 |
