A modern, comprehensive, production-ready test automation framework with Visual Regression, Performance Testing, Accessibility Testing, and Mobile Emulation
Features β’ Quick Start β’ Commands β’ Documentation β’ Examples
This framework provides a complete testing solution for modern web applications, combining the power of Playwright with Cucumber BDD, enhanced with enterprise-grade features including Visual Regression, Performance Monitoring, Accessibility Compliance, and Mobile Device Testing.
- β All-in-One Solution: UI, API, Visual, Performance, Accessibility, Mobile - everything included
- β Production-Ready: Battle-tested with comprehensive error handling and diagnostics
- β Developer-Friendly: TypeScript with excellent IDE support and type safety
- β Business-Readable: Cucumber's Gherkin syntax for stakeholder collaboration
- β Fast & Reliable: Parallel execution, auto-waiting, and smart retry mechanisms
- β Quality-First: Built-in performance budgets, accessibility checks, and visual comparisons
- π Playwright Integration - Modern, reliable cross-browser automation
- π₯ Cucumber BDD - Write tests in plain English using Gherkin syntax
- π TypeScript - Full type safety and excellent developer experience
- ποΈ Page Object Model - Maintainable, scalable test architecture
- π World Pattern - Proper test isolation and state management
- π Full REST API Support - GET, POST, PUT, PATCH, DELETE
- π Authentication Management - Token-based auth handling
- β Response Assertions - Built-in status and content validation
- π Request/Response Logging - Automatic logging with performance metrics
- π Hybrid Testing - Seamlessly combine API and UI tests
- πΈοΈ Traffic Capture - Monitor all network requests/responses
- π API Mocking - Mock external dependencies for deterministic tests
- π« Resource Blocking - Block ads, analytics, fonts for faster execution
- π Network Simulation - Test slow connections and offline scenarios
- π Performance Metrics - Track request durations and patterns
- πΈ Screenshot Comparison - Pixel-perfect visual regression testing
- π¨ Element Comparison - Test specific components independently
- π Dynamic Content Masking - Hide changing elements (dates, counters)
- π± Responsive Testing - Compare across multiple viewports
- π― Hover/Focus States - Test interactive element states
- π Custom Thresholds - Configurable tolerance for differences
- β‘ Web Vitals - FCP, LCP, CLS, TTI, TBT measurements
- π Performance Budgets - Set and enforce performance thresholds
- π― Performance Scoring - 0-100 score based on metrics
- π Resource Analysis - Identify slowest/largest resources
- β±οΈ TTFB Measurement - Time to First Byte tracking
- π Automated Reports - Detailed performance reports with violations
- βΏ WCAG Compliance - WCAG 2.0, 2.1, 2.2 Level A, AA, AAA
- π axe-core Integration - Industry-standard accessibility testing
- π¨ Color Contrast - Automatic contrast ratio checking
- π Form Validation - Label and input accessibility checks
- πΌοΈ Image Alt Text - Verify all images have descriptions
- β¨οΈ Keyboard Navigation - Test keyboard accessibility
- π Accessibility Scoring - Get compliance scores (0-100)
- π± 20+ Devices - iPhone, iPad, Android phones, tablets
- π Touch Gestures - Tap, swipe, pinch, long press
- π Device Rotation - Portrait/landscape testing
- π Geolocation - Test location-based features
- π‘ Network Conditions - Emulate 3G, 4G, WiFi, offline
- π Responsive Breakpoints - Test all common screen sizes
- β‘ Parallel Execution - Run tests concurrently (2-8+ workers)
- π Multi-Browser Support - Chromium, Firefox, WebKit
- π― Multi-Environment - Dev, Staging, Production, CI configurations
- π·οΈ Tag-Based Filtering - Run specific suites (@smoke, @regression, @api, @visual, etc.)
- π Smart Retry Logic - Exponential backoff for flaky tests
- π¬ Debug Mode - Headed browser with slow motion for troubleshooting
- πΈ Screenshots on Failure - Automatic capture with timestamping
- π₯ Video Recording - Configurable modes (on-failure, always, first-retry)
- π Playwright Traces - Deep debugging with timeline and network logs
- π Advanced Logging - Winston-based structured logging with levels
- π¨ Colored Console Output - Easy-to-read test execution logs with emojis
- π§ Error Diagnostics - Context capture, stack traces, page state
- πΈοΈ Network Logs - Request/response capture in traces
- π» Browser Console - Capture and attach console logs
- π Standard Cucumber HTML - Feature/scenario breakdown
- β¨ Enhanced HTML Summary - Beautiful reports with charts and statistics
- π JSON Reports - Machine-readable for integrations
- π JUnit XML - For CI/CD integration
- π― Performance Reports - Detailed Web Vitals and budget violations
- βΏ Accessibility Reports - WCAG violations with remediation guidance
- πΈ Visual Diff Reports - Side-by-side comparisons with highlights
- π GitHub Actions Ready - Pre-configured workflow included
- π³ Docker Support - Containerized execution (coming soon)
- π§ Environment Variables - Easy configuration management
- π¦ Artifact Upload - Screenshots, videos, traces, reports
- π― Quality Gates - Fail builds on budget violations or accessibility issues
- ποΈ Centralized Configuration - Single source for all settings
- π Retry Logic - Smart exponential backoff
- π‘οΈ Error Handling - Comprehensive error utilities
- π Code Quality - ESLint and Prettier configurations
- π¦ Type Safety - Full TypeScript throughout
- π Comprehensive Docs - Detailed guides for all features
- π Example Tests - Real-world examples for every feature
- ποΈ Static Data Repository - Predefined users, products, checkout info
- π² Dynamic Generation - Random usernames, emails, passwords
- π File-Based Loading - JSON data files with caching
- π Environment-Specific - Different data per environment
- ποΈ Data Builders - Fluent API for test data creation
- Node.js >= 18.x
- npm >= 9.x
- Basic understanding of TypeScript and Cucumber BDD
# Clone the repository
git clone https://github.com/yourusername/playwright-cucumber-framework.git
cd playwright-cucumber-framework
# Install dependencies
npm install
# Install Playwright browsers
npx playwright install
# Copy environment configuration
cp .env.example .env
# Edit .env with your settings
nano .env# Run all tests
npm test
# Run smoke tests only
npm run test:smoke
# Run in debug mode (visible browser)
npm run test:debug
# View report
npm run reportnpm test # Run all tests
npm run test:smoke # Quick critical path tests
npm run test:regression # Full regression suite
npm run test:parallel # Parallel execution (2 workers)
npm run test:parallel:4 # Parallel with 4 workers
npm run test:debug # Debug mode (headed + slow motion)npm run test:ui # UI tests only
npm run test:api # API tests only
npm run test:visual # Visual regression tests
npm run test:performance # Performance tests
npm run test:accessibility # Accessibility tests
npm run test:a11y # Alias for accessibility
npm run test:mobile # Mobile device tests
npm run test:responsive # Responsive design tests
npm run test:network # Network monitoring tests
npm run test:mock # Tests with API mocking
npm run test:advanced # All advanced tests
npm run test:quality # Complete quality assessmentnpm run test:dev # Development environment
npm run test:staging # Staging environment
npm run test:prod # Production environment
npm run test:ci # CI-optimized (with compilation)npm run test:chromium # Google Chrome/Edge
npm run test:firefox # Mozilla Firefox
npm run test:webkit # Safarinpm run test:headed # Visible browser
npm run test:blocked # Block ads/analytics
npm run snapshots:update # Update visual baselinesnpm run report # Open enhanced HTML report
npm run report:cucumber # Open standard Cucumber report
npm run clean # Clean all artifacts
npm run clean:reports # Clean reports only
npm run clean:snapshots # Clean visual snapshots
npm run compile # Compile TypeScript
npm run lint # Run ESLint
npm run format # Format with Prettierplaywright-cucumber-framework/
βββ .github/
β βββ workflows/
β βββ playwright-tests.yml # CI/CD pipeline
βββ config/
β βββ test.config.ts # Centralized configuration
βββ src/
β βββ accessibility/
β β βββ accessibility-helper.ts # WCAG compliance testing
β βββ api/
β β βββ api-client.ts # REST API testing
β βββ mobile/
β β βββ mobile-helper.ts # Device emulation
β βββ performance/
β β βββ performance-helper.ts # Web Vitals & budgets
β βββ utils/
β β βββ error-handler.ts # Error handling
β β βββ logger.ts # Winston logger
β βββ visual/
β β βββ visual-testing.ts # Visual regression
β βββ web/
β βββ actions.ts # Web actions
β βββ network-helper.ts # Network mocking
βββ tests/
β βββ data/
β β βββ test-data-manager.ts # Test data management
β βββ features/
β β βββ shopping.feature # UI test scenarios
β β βββ api-example.feature # API test scenarios
β β βββ advanced-testing.feature # Advanced features
β βββ pages/
β β βββ login.page.ts # Page objects
β β βββ products.page.ts
β β βββ cart.page.ts
β βββ steps/
β β βββ shopping.steps.ts # Step definitions
β β βββ api.steps.ts
β β βββ advanced.steps.ts
β βββ support/
β β βββ world.ts # Cucumber World
β β βββ hooks.ts # Test hooks
β β βββ custom-reporter.ts # Custom reporter
β βββ test-results/ # Test artifacts
β βββ reports/
β β βββ cucumber-report.html
β β βββ summary.html
β β βββ enhanced-report.json
β βββ screenshots/
β β βββ snapshots/
β βββ videos/
β βββ traces/
βββ logs/
β βββ error.log
β βββ combined.log
βββ .env.example # Environment template
βββ .gitignore
βββ cucumber.config.js
βββ tsconfig.json
βββ package.json
βββ README.md # This file
βββ TEST_COMMANDS.md # Complete command reference
βββ PHASE2_FEATURES.md # API & Network features
βββ PHASE3_FEATURES.md # Visual, Perf, A11y, Mobile
βββ FRAMEWORK_COMPLETE.md # Final summary
Feature File (tests/features/shopping.feature):
@ui @smoke
Feature: Shopping Cart
Scenario: Add item to cart
Given I am on the Sauce Demo login page
When I login with standard user credentials
And I add "Sauce Labs Backpack" to cart
And I navigate to cart
Then I should see "Sauce Labs Backpack" in my cartStep Definition (tests/steps/shopping.steps.ts):
When('I add {string} to cart', async function(this: TestWorld, productName: string) {
this.scenarioLogger.step(`Adding product "${productName}" to cart`);
await this.productsPage.addToCart(productName);
this.scenarioLogger.info(`Product "${productName}" added to cart`);
});Page Object (tests/pages/products.page.ts):
export class ProductsPage {
constructor(private page: Page, private actions: WebActions) {}
async addToCart(productName: string): Promise<void> {
const selector = `//div[text()="${productName}"]//button`;
await this.actions.click(selector);
}
}Feature File:
@api @smoke
Feature: User API
Scenario: Create new user
Given I have a valid API authentication token
When I make a POST request to "/api/users" with:
| name | John Doe |
| email | john@test.com |
Then the API response status should be 201
And the API response should be valid JSONStep Definition:
When('I make a POST request to {string} with:', async function(this: TestWorld, endpoint: string, dataTable) {
const data = dataTable.rowsHash();
const response = await this.apiClient.post(endpoint, data);
(this as any).lastApiResponse = response;
});Feature File:
@visual @regression
Feature: Visual Regression
Scenario: Products page visual check
Given I am on the products page
When I compare the page visually as "products-page"
Then all visual comparisons should passFeature File:
@performance @smoke
Feature: Page Performance
Scenario: Page load performance
Given I am on the products page
When I measure page load performance
Then the page should load within 3000ms
And the performance score should be at least 80Feature File:
@accessibility @wcag
Feature: Accessibility Compliance
Scenario: WCAG AA compliance
Given I am on the products page
When I run an accessibility scan
Then there should be no critical accessibility violations
And the page should be WCAG "AA" compliantFeature File:
@mobile @responsive
Feature: Mobile Testing
Scenario: iPhone 13 testing
Given I am using a "iPhone_13" device
And I am on the products page
When I tap on ".add-to-cart"
Then the item should be added to cartStep Definition:
Given('I mock the API response for {string}', async function(this: TestWorld, urlPattern: string) {
await this.networkHelper.mockApiResponse(urlPattern, {
status: 200,
body: { success: true, data: [...] }
});
});import { TestData, DataBuilder } from '../data/test-data-manager';
// Static data
const user = TestData.users.standard;
await this.loginPage.login(user.username, user.password);
// Dynamic data
const randomUser = DataBuilder.generateUserCredentials();
const checkoutInfo = DataBuilder.generateCheckoutInfo();After running tests, find reports in test-results/:
-
Enhanced HTML Summary (
reports/summary.html)- Visual success rate display
- Test statistics with charts
- Slowest scenarios
- Failed scenarios with errors
- Test metadata
-
Standard Cucumber HTML (
reports/cucumber-report.html)- Feature-by-feature breakdown
- Scenario details
- Step execution times
-
Enhanced JSON (
reports/enhanced-report.json)- Machine-readable format
- Performance metrics
- Budget violations
- For custom integrations
-
Performance Reports (
performance/performance-report.json)- Web Vitals metrics
- Resource timing
- Budget violations
- Performance score
-
Accessibility Reports (
accessibility/a11y-report.json)- WCAG violations
- Impact levels
- Remediation guidance
- Accessibility score
Automatically captured when tests fail:
- Screenshots -
screenshots/*.png - Videos -
videos/*.webm - Traces -
traces/*.zip(view withnpx playwright show-trace) - Visual Diffs -
screenshots/snapshots/*-diff.png - Network Logs - Included in traces
- Console Logs - Attached to Cucumber report
- Page HTML - Attached to report
# Open enhanced summary
npm run report
# Open Cucumber report
npm run report:cucumber
# View traces
npx playwright show-trace test-results/traces/scenario.zip
# View logs
tail -f logs/combined.log
cat logs/error.log# Environment
TEST_ENV=dev # dev, staging, prod, ci
NODE_ENV=development
# Browser
BROWSER=chromium # chromium, firefox, webkit
HEADLESS=false # true, false
SLOW_MO=0 # Delay in ms
TIMEOUT=30000 # Default timeout in ms
# Viewport
VIEWPORT_WIDTH=1920
VIEWPORT_HEIGHT=1080
# Execution
PARALLEL_WORKERS=1 # Number of parallel workers
RETRIES=2 # Test retry count
# Logging
LOG_LEVEL=info # error, warn, info, debug
# Video Recording
VIDEO_RECORDING=true
VIDEO_MODE=retain-on-failure # on, off, retain-on-failure, on-first-retry
# Screenshots
SCREENSHOT_ON_FAILURE=true
# Tracing
TRACE_ENABLED=true
TRACE_MODE=retain-on-failure
# Visual Testing
VISUAL_THRESHOLD=0.2
VISUAL_MAX_DIFF_PIXELS=100
# Performance
PERF_BUDGET_LOAD=3000
PERF_BUDGET_FCP=1800
PERF_BUDGET_LCP=2500
# Accessibility
A11Y_LEVEL=AA # A, AA, AAA
A11Y_FAIL_ON_VIOLATIONS=false
# Mobile
DEFAULT_MOBILE_DEVICE=iPhone_13
MOBILE_NETWORK=4g
# CI/CD
CI=falseThe framework automatically loads environment-specific configuration:
// Development
TEST_ENV=dev npm test
// Staging
TEST_ENV=staging npm test
// Production
TEST_ENV=prod npm test
// CI
TEST_ENV=ci npm run test:ciThe framework includes a ready-to-use GitHub Actions workflow:
# .github/workflows/playwright-tests.yml
name: Playwright Tests
on: [push, pull_request, workflow_dispatch]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
browser: [chromium, firefox, webkit]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npx playwright install --with-deps
- run: npm run test:ci
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: test-results/- Go to GitHub Actions tab
- Select "Playwright Cucumber Tests"
- Click "Run workflow"
- Choose:
- Environment (dev/staging/prod)
- Browser (chromium/firefox/webkit/all)
- Parallel workers (1-8)
Jenkins:
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'npm ci'
sh 'npx playwright install --with-deps'
sh 'npm run test:ci'
}
}
stage('Report') {
steps {
publishHTML([
reportDir: 'test-results/reports',
reportFiles: 'summary.html',
reportName: 'Test Report'
])
}
}
}
}GitLab CI:
test:
image: mcr.microsoft.com/playwright:latest
script:
- npm ci
- npm run test:ci
artifacts:
paths:
- test-results/
when: alwaysβ Group tests by feature/domain β Use meaningful, descriptive scenario names β Tag appropriately (@smoke, @regression, @api, etc.) β Keep scenarios focused and independent β Use Background for common setup
β One class per page/component β Encapsulate all selectors β Return promises consistently β Add comprehensive JSDoc comments β Use meaningful method names
β Use static data for known scenarios β Generate dynamic data for variety/uniqueness β Never commit real credentials β Use environment-specific data β Keep test data DRY
β Mask dynamic content (dates, counters, ads) β Run on consistent environment β Update baselines intentionally β Test multiple viewports β Use descriptive snapshot names
β Set realistic performance budgets β Test on representative hardware β Block unnecessary resources β Monitor trends over time β Test both cold and warm loads
β Test every page and component β Aim for WCAG AA minimum β Fix critical issues first β Test with keyboard navigation β Validate with screen readers
β Test on real device viewports β Test portrait and landscape β Emulate real network conditions β Test touch interactions β Cover iOS and Android
β Run smoke tests on every commit β Run full regression nightly β Archive test artifacts β Monitor quality metrics β Fail builds on critical issues
- README.md - This comprehensive guide
Browsers not found:
npx playwright install --with-depsTypeScript errors:
npm run compileTests failing randomly:
# Increase timeout
TIMEOUT=60000 npm test
# Reduce parallel workers
PARALLEL_WORKERS=1 npm test
# Check for race conditionsVisual tests failing:
# View diffs
open test-results/screenshots/snapshots/*-diff.png
# Update baselines if intentional
npm run snapshots:updatePerformance tests slow:
# Check network conditions
# Block unnecessary resources
npm run test:blockedAccessibility violations:
# View detailed report
cat test-results/accessibility/a11y-report.json
# Fix critical issues first
npm run test:accessibility- Check documentation files
- Review logs:
logs/combined.log - View traces:
npx playwright show-trace - Create GitHub issue with:
- Error message
- Steps to reproduce
- Environment details
- Relevant logs
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
npm test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- β All tests must pass
- β Follow TypeScript best practices
- β Add tests for new features
- β Update documentation
- β Follow existing code style
- β Write clear commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
- Playwright - Modern browser automation
- Cucumber - BDD framework
- TypeScript - Type-safe JavaScript
- Winston - Logging library
- axe-core - Accessibility testing
- π§ Email: avinash.pagunta@gmail.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Documentation: See documentation files in repository
# 1. Install
npm install
npx playwright install
# 2. Configure
cp .env.example .env
# 3. Run tests
npm test
# 4. View reports
npm run report
# 5. Try advanced features
npm run test:visual
npm run test:performance
npm run test:accessibility
npm run test:mobileBuilt with β€οΈ by QA Engineers, for QA Engineers
If this framework helped you, please consider giving it a βοΈ
Documentation β’ Commands β’ Examples β’ Contributing
Framework Version: 1.0.0
Last Updated: 2025-11-05
Status: Production Ready β