playwright-automation-framework
Enterprise-grade, scalable end-to-end automation framework for web and API testing, built on MCP (Model Context Protocol) for dynamic, JSON-driven test generation, self-healing execution, and robust reporting. Designed for reliability, maintainability, and scalability.
tests/— Feature-based folders (e.g.,auth/,cart/,checkout/,product/) with.spec.jstest filespages/— Page Object Model (POM) classes for UI interactionsreports/— Screenshots and Playwright HTML reportsplaywright.config.js— Central configuration for browsers, parallelism, retries, tracing, and reportingpackage.json— Scripts and dependencies
📢 Key Highlights & Additions (click to expand)
- API Testing Support: API tests live in
tests/API_Testing/and run as a separate Playwright project (API-Testsinplaywright.config.js). - Excel-to-JSON Automation: Use
GetTestCase_Automation/getTestCaseDetails.jsto convertSauceLabs_TestCases.xlsxto JSON for MCP-driven test generation. - Test Utilities:
testcase_utils/is reserved for custom helpers/utilities (future extensibility). - Menu & Footer Page Objects:
menu.page.jsandproducts.page.jsprovide reusable navigation, logout, and footer/social link assertions. - Extensibility: Easily add new page objects, test data, and flows. Reserved folders like
tests/product/for future product-specific tests. - Naming Conventions: Test files:
feature-name.spec.js, Page objects:feature.page.js. - How to Add a New Test Case:
- Update
SauceLabs_TestCases.xlsxwith new scenarios. - Run
node GetTestCase_Automation/getTestCaseDetails.jsto generate JSON. - Run MCP to generate and execute tests automatically.
- Update
- Allure Reports: Generated in
allure-report/and can be served locally withnpx allure serve allure-results. - Contact/Contributing: For contributions or questions, contact the maintainer or open an issue.
🚀 Modern, maintainable, and scalable Playwright automation with dynamic test generation via Model Context Protocol (MCP).
SDET_Playwright/
├── tests/ # Feature-based test specs (auth, cart, checkout, ...)
├── pages/ # Page Object Model (POM) classes
├── fixtures/ # Shared test data (JSON)
├── reports/ # Screenshots, HTML & Allure reports
├── playwright.config.js
├── package.json
└── ...
-
GetTestCase_Automation/: Excel-to-JSON automation for test case management
-
testcase_utils/: Reserved for custom test helpers/utilities
-
allure-report/: Allure HTML reports (generated)
-
playwright-report/: Playwright HTML reports (generated)
-
SauceLabs_TestCases.xlsx: Source Excel for test scenarios
-
tests/: Organized by feature, contains
.spec.jsfiles (MCP-generated & manual) -
pages/: POM classes encapsulating UI logic and selectors
-
fixtures/: Test data, credentials, expected values
-
reports/: Allure, Playwright HTML, and MCP result summaries
# 1. Install dependencies
npm ci
npm i -D allure-playwright
# 2. Run all tests
npx playwright test
# 3. Run a specific test
npx playwright test tests/auth/login.spec.js
# 4. View Playwright HTML report
npx playwright show-report
# 5. Generate & serve Allure report
npx allure-playwright generate
npx allure serve allure-results- MCP enables dual workflow:
- 💻 Workflow A: Real-time browser execution & validation
- 📄 Workflow B: Auto-generates Playwright test code (POM-based, with strict grouping, hooks, tags, comments, and log messages)
- Test cases defined in
TestCaseDetails/test_cases_details.json - Instructions in
PlaywrightMCP_Instructions/playwright_mcp_instructins.md - POM & test script standards in
pom_structure_instructions.md
- Add/Update test cases in JSON
- Run MCP (see instructions)
- MCP executes steps, validates, and generates code
- Test is saved in
tests/and executed until pass - All generated scripts follow mandatory grouping, hooks, tags, comments, and log message standards
- Results summarized in
reports/
| Path | Purpose |
|---|---|
tests/ |
All test specs (feature-based) |
pages/ |
Page Object Model classes |
fixtures/test-data.json |
Shared test data, credentials, expected vals |
reports/ |
Screenshots, HTML, Allure, MCP result JSON |
playwright.config.js |
Playwright config (projects, reporters, CI) |
PlaywrightMCP_Instructions/playwright_mcp_instructins.md |
MCP test generation/execution instructions |
PlaywrightMCP_Instructions/pom_structure_instructions.md |
POM structure & standards |
GetTestCase_Automation/TestCaseDetails/test_cases_details.json |
Source of truth for test scenarios |
| GetTestCase_Automation/getTestCaseDetails.js | Converts Excel test cases to JSON for MCP |
| SauceLabs_TestCases.xlsx | Source Excel for test scenarios |
| testcase_utils/ | Reserved for custom test helpers/utilities |
| allure-report/ | Allure HTML reports (generated) |
| playwright-report/ | Playwright HTML reports (generated) |
- Zero manual scripting: Add scenarios in JSON, MCP generates & executes
- Strict POM enforcement: All selectors/actions via page classes
- Allure & Playwright HTML reporting
- API + UI + Integration test support
- CI-ready & BrowserStack integration
- Reusable test data & fixtures
- Professional code quality & structure
- POM: All UI logic in
pages/, never inline selectors in tests - Test data: Centralized in
fixtures/test-data.json - Specs: Named by feature, grouped in
tests/ - Reporting: Allure & Playwright HTML for traceability
- CI: Use environment variables for secrets (see
playwright.config.js) - API Testing: Place API-only specs in
tests/API_Testing/and use theAPI-Testsproject for separation. - Menu/Footer: Use
menu.page.jsandproducts.page.jsfor navigation, logout, and footer assertions. - Extensibility: Add new page objects and test flows as needed; reserved folders for future growth.
- All MCP-generated test scripts must:
- Use
test.describeto group related test cases by flow or feature - Use Playwright hooks (
beforeEach,afterEach, etc.) for setup/teardown - Annotate each test with the appropriate tag(s):
@smoke,@regression,@sanity - Add clear comment statements before each logical block (setup, action, assertion, teardown)
- Insert
console.logmessages at key steps for traceability - Ensure all code is clean, DRY, and maintainable.
- Use
- If
npx playwright testreports "No tests found", check file naming/location - Avoid
test.onlyunless debugging - Use
test.describe.serialfor ordered, stateful tests - For API mocks, tolerate non-persistence (see code comments)
- Use
page.evaluate()andpage.addInitScript()for advanced browser state setup
- BrowserStack integration in
playwright.config.js - Set credentials via environment variables:
# Windows PowerShell
$env:BROWSERSTACK_USERNAME='your_user'
$env:BROWSERSTACK_ACCESS_KEY='your_key'- getTestCaseDetails.js: Converts Excel test cases to JSON for MCP
- TestCaseDetails/: Stores generated JSON for automated test runs
Made by Suresh Babu S
For questions, contributions, or support, please contact.:- 8073372170 - Suresh Babu S