by padmarajnidagundi
Facilitates automated web, API, accessibility, security, resilience, and mobile testing using Playwright with a Page Object Model architecture integrated with an MCP server for AI‑assisted test execution and healing.
Enables end‑to‑end testing across browsers, APIs, accessibility, security, and mobile platforms. It combines Playwright’s robust testing capabilities with a Page Object Model structure and an MCP server that allows AI agents to run, analyze, and heal tests through guarded, POM‑centric tooling.
npm ci
npx playwright install --with-deps
export E2E_BASE_URL="https://your-app.example.com"
(Windows PowerShell: $env:E2E_BASE_URL="https://your-app.example.com")npm run test:smoke # run the smoke suite in Chromium
npm run test:chromium # full suite in Chromium
npm run test:headed # interactive mode
npm run test:report # open HTML report
npm run mcp:server
tests/pages/*Page.ts; specs focus on business behavior.tests/data/.test-results/ai-report.json),docker‑compose up --build tests for containerised execution.test:security and test:a11y suites to catch XSS, authentication issues, and WCAG violations.Q: What Node version is required? A: Node.js 20 or newer.
Q: How are secrets handled? A: Store tokens and credentials in environment variables or CI secrets; the framework redacts them from AI reports.
Q: Can I run tests in parallel? A: Yes, Playwright’s built‑in parallelism works out of the box; CI limits workers automatically.
Q: What if a locator changes?
A: Inspect test-results/error-context.md or the Playwright trace, update the selector in the relevant *Page.ts, then re‑run the failing spec.
Q: Do I need additional reporting libraries? A: No. Playwright’s HTML reporter, JSON, JUnit, screenshots, and traces are included.
Q: How do I extend the framework for custom utilities?
A: Add helpers under tools/ or create additional fixtures in tests/fixtures.ts and import them in specs.
Q: Is the MCP server mandatory for test execution? A: It is required only for AI‑assisted operations (failure analysis, locator healing). Standard Playwright runs work without it.
A practical Playwright, Page Object Model (POM), and AI-agent testing framework for web, API, accessibility, security, resilience, and mobile checks.
Choose the workflow that matches the task:
| Role | Start here | Primary checks |
|---|---|---|
| Developer adding a journey | Add centralized data and a Page Object, then add a spec in the matching tests/ category. |
npm run typecheck, a focused Playwright spec, and npm run format:check |
| QA engineer validating a release | Configure E2E_BASE_URL, run smoke or project coverage, and inspect reports and traces. |
npm run test:smoke, npm run test:chromium, and npm run test:report |
| AI-assisted maintainer | Start the MCP server, run or analyze the smallest relevant suite, then review any locator proposal. | npm run mcp:server, test-results/ai-report.json, and traces |
The main conventions are:
tests/data/.tests/pages/*Page.ts.tests/**/*.spec.ts.data-testid locators.For a first local run:
npm ci
npx playwright install --with-deps
export E2E_BASE_URL="https://qa.example.com"
npm run test:smoke
On Windows PowerShell:
npm ci
npx playwright install --with-deps
$env:E2E_BASE_URL="https://qa.example.com"
npm run test:smoke
Use this guide to adopt the framework for an application or team. The repository is ready for QA automation once the setup steps below are complete; no additional test runner or reporting package is required.
Start with a non-production environment. Set E2E_BASE_URL to the application URL
that Playwright should test:
export E2E_BASE_URL="https://qa.example.com"
npm run test:smoke
On Windows PowerShell:
$env:E2E_BASE_URL="https://qa.example.com"
npm run test:smoke
Store tokens and other secrets in CI secrets or environment variables. Do not place
credentials in specs, Page Objects, or tests/data/.
Prerequisite: Node.js 20+.
npm ci
npx playwright install --with-deps
npm run test:smoke
npm run test:chromium
npm run test:report
The first smoke run confirms that dependencies, browsers, network access, and the target environment work together. Use headed mode during local investigation:
npm run test:headed
For a single journey:
npx playwright test tests/indiaRealtime.spec.ts --project=chromium --headed
npx playwright test tests/security-tests/ --project=chromium
Add centralized application data under tests/data/:
Create a Page Object under tests/pages/ for each high-value user-facing page or
component. Put selectors and UI actions in the Page Object, while specs should
describe the scenario and assert the expected business behavior.
Recommended workflow for the first new journey:
tests/data/.data-testid locators.tests/.npm run typecheck.Example spec and POM structure:
// tests/pages/LoginPage.ts
import { Page, expect } from '@playwright/test';
import { BasePage } from './BasePage';
export class LoginPage extends BasePage {
readonly url = '/login';
constructor(page: Page) {
super(page);
}
async open() {
await this.goto(this.url);
}
async expectReady() {
await expect(this.page.getByRole('heading', { name: 'Login' })).toBeVisible();
}
}
// tests/e2e/login.spec.ts
import { test } from '@playwright/test';
import { LoginPage } from '../pages/LoginPage';
test('login page is available', async ({ page }) => {
const login = new LoginPage(page);
await login.open();
await login.expectReady();
});
Place specs in the category that matches their purpose:
| QA need | Directory |
|---|---|
| Browser critical journeys | tests/e2e/ or tests/indiaRealtime.spec.ts |
| Accessibility | tests/accessibility/ |
| API contracts | tests/contract-tests/ |
| Authentication and injection | tests/security-tests/ |
| Mobile behavior | tests/mobile.spec.ts |
| Integration workflows | tests/integration-tests/ |
| Network failures and resilience | tests/network-resilience/ or tests/resilience/ |
| Validation and invalid routes | tests/validation-tests/ |
On pushes and pull requests targeting main or develop, CI performs formatting,
unit, integration, and smoke checks. The CI workflow also audits dependencies and
scans changed commits for secrets. Treat these blocking checks as merge criteria:
npm run format:check
npm run typecheck
npm run test:unit
npm run test:integration
npm run test:smoke
CI uploads Playwright HTML reports, JSON/JUnit results, screenshots, traces, and
videos when available. Add E2E_BASE_URL, E2E_API_TOKEN, and any other required
test configuration to the CI environment or repository secrets.
For a failing run:
--headed or --debug.test-results/ai-report.json for the normalized status and root-cause hints.test-results/error-context.md, the Playwright trace, or HTML report.Do not put fixed sleeps in tests. Prefer Playwright locators and assertions, response waiting, and Page Object wait helpers. If a locator change is proposed by an AI tool, review the POM diff and rerun the affected tests before applying it.
Requirements: Node.js 20+.
npm ci
npx playwright install --with-deps
npm run test:smoke
Use Chromium for the fastest local feedback:
npm run test:chromium
npm run test:headed
npm run test:report
Set a target application with an environment variable:
E2E_BASE_URL=https://your-app.example npm run test:smoke
E2E_API_TOKEN=your-token npm run test:chromium
PowerShell:
$env:E2E_BASE_URL="https://your-app.example"
npm run test:smoke
| Command | Purpose |
|---|---|
npm test |
Run the complete configured suite |
npm run test:unit |
Run platform and utility unit tests |
npm run test:integration |
Run integration tests |
npm run test:smoke |
Run the smoke suite in Chromium |
npm run test:a11y |
Run accessibility and keyboard checks |
npm run test:security |
Run security-focused Playwright specs |
npm run test:mobile |
Run mobile-project coverage |
npm run test:chromium |
Run the full suite in Chromium |
npm run test:headed |
Run in headed mode |
npm run test:report |
Open the HTML report |
npm run typecheck |
Check TypeScript types |
npm run format:check |
Check formatting |
npm run mcp:server |
Start the JSON-RPC/MCP server |
To run one spec or category:
npx playwright test tests/indiaRealtime.spec.ts --project=chromium
npx playwright test tests/security-tests/ --project=chromium
npx playwright test tests/indiaRealtime.spec.ts --project=chromium --headed
AI agent / MCP client
|
v
mcp-server.ts ── test selection, failure analysis, reporting, guarded healing
|
v
Playwright runner
|
+-- tests/*.spec.ts
+-- tests/pages/*Page.ts
+-- tests/data/*.ts
+-- tools/ai-reporter.ts
+-- tools/platform/*
tests/data/; configure URLs and tokens through environment variables.tests/
data/ Centralized URLs, users, thresholds
pages/ Page Objects and shared BasePage
fixtures.ts Shared Playwright fixtures
indiaRealtime.spec.ts Main smoke coverage
unit-tests/ Fast platform tests
integration-tests/ Multi-step workflows
accessibility/ Axe and keyboard checks
security-tests/ Authentication and XSS checks
validation-tests/ Broken links and invalid inputs/routes
network-resilience/ Offline/network scenarios
contract-tests/ API contract checks
...
tools/
ai-reporter.ts Structured run output
platform/ Failure analysis, trace summaries, healing,
test selection, metrics, and redaction
mcp-server.ts MCP/JSON-RPC entrypoint
playwright.config.ts Browser projects and reporters
Create a Page Object for UI selectors and actions:
import { Page, expect } from '@playwright/test';
import { BasePage } from './BasePage';
export class LoginPage extends BasePage {
readonly url = '/login';
constructor(page: Page) {
super(page);
}
async open() {
await this.goto(this.url);
}
async submit(username: string) {
await this.safeFill(this.page.getByLabel('Username'), username, 'username');
}
async expectReady() {
await expect(this.page.getByRole('heading', { name: 'Login' })).toBeVisible();
}
}
Keep the spec focused on behavior:
import { test, expect } from '@playwright/test';
import { LoginPage } from './pages/LoginPage';
test('shows login form', async ({ page }) => {
const login = new LoginPage(page);
await login.open();
await login.expectReady();
});
Prefer role, label, and data-testid locators. Use Playwright waits and assertions instead of fixed sleeps.
After a run, AI tools can consume:
test-results/ai-report.json — normalized test status and root-cause hintstest-results/results.json — standard Playwright JSONjunit.xml — CI/JUnit outputplaywright-report/ — visual HTML reporttest-results/<test>/trace.zip — Playwright traceThe MCP server exposes tools for listing specs, running tests, reading results, analyzing failures, generating test previews, selecting impacted tests, and proposing/validating guarded locator repairs.
Start it locally:
npm run mcp:server
The server exposes these MCP tools:
| Tool | Use |
|---|---|
run_tests |
Run Playwright tests with an optional filter, browser project, or shards. |
get_test_results |
Read the normalized test-results/ai-report.json result. |
list_test_files |
Discover available specs under tests/. |
analyze_failures |
Group failures by category and probable root cause. |
get_trace_summary |
Summarize trace artifacts for all failures or a test title. |
generate_test_preview |
Preview a POM-aligned test before generating or editing files. |
propose_locator_repair |
Create a guarded locator repair proposal. |
apply_locator_repair |
Apply an approved repair only through the POM guardrails. |
validate_healing_rerun |
Re-run impacted specs and compare the healing result. |
get_dashboard_metrics |
Build dashboard metrics from archived reports. |
select_tests_for_changes |
Select the tests impacted by changed file paths. |
For AI-assisted debugging:
test-results/ai-report.json.tests/pages/*Page.ts.Healing tools are intentionally POM-only. Applying locator changes may require approval according to risk, and validation should compare the rerun before and after.
The repository provides three modern custom agents in .github/agents/:
Agent example: select playwright-generator and enter:
Generate a deterministic Chromium smoke spec for https://indiarealtime.com.
Verify the homepage, capture accessibility basics, and open the first article.
Put UI locators in tests/pages/IndiaRealTimePage.ts and use tests/data/urls.ts.
Run npm run test:smoke after generation.
The same agent workflow supports 2026/2027 maintenance:
| Variable | Default | Purpose |
|---|---|---|
E2E_BASE_URL |
https://indiarealtime.com |
Base URL for browser and API fixtures |
E2E_API_TOKEN |
unset | Optional bearer token for API requests |
CI |
unset | Enables CI retries and worker limits |
Authentication and sensitive values should remain in environment variables or CI secrets. The framework redacts secrets in AI report output and healing records.
The default configuration includes Chromium, Firefox, WebKit, Mobile Chrome (Pixel 5), and Mobile Safari (iPhone 12).
npx playwright test --project=chromium
npx playwright test --project=firefox
npx playwright test --project=webkit
npx playwright test tests/mobile.spec.ts --project="Mobile Chrome"
npx playwright test tests/mobile.spec.ts --project="Mobile Safari"
Install all browsers once with:
npx playwright install --with-deps
docker-compose up --build tests
Override the target by updating docker-compose.yml or passing E2E_BASE_URL in the local environment. Docker output is written to mounted Playwright and test-result directories.
GitHub Actions runs formatting, unit, integration, smoke, security/audit, and secret-scanning checks. Unit and integration suites remain blocking; extended suites are clearly separated for faster feedback.
CI artifacts include HTML reports, JSON/JUnit results, traces, screenshots, and videos.
| Problem | Fix |
|---|---|
| Browsers missing | npx playwright install --with-deps |
| Locator changed | Inspect test-results/error-context.md or the trace, then update the POM |
| Target unavailable | Set E2E_BASE_URL and verify network/DNS access |
| MCP server unavailable | Run npm ci && npm run mcp:server |
| Formatting fails | npm run format |
| Type failures | npm run typecheck |
Debug a single spec:
npx playwright test tests/indiaRealtime.spec.ts --project=chromium --headed --debug
npx playwright show-trace test-results/<test-name>/trace.zip
npx playwright show-report
MIT. See LICENSE.
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by headroomlabs-ai
Compress tool outputs, logs, files, RAG chunks, and conversation history before they reach the LLM, keeping answers identical while saving up to 95% of tokens for JSON payloads.
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.