Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

Repository files navigation

πŸ§ͺ Playwright MCP Automation with Allure Reports

Playwright TypeScript Node.js Jenkins AI Powered

πŸš€ AI-Powered End-to-End Testing with Visual Reports

Harness the power of GPT-4.1 to generate, execute, and refine Playwright tests automatically

Features β€’ Quick Start β€’ CI/CD β€’ Documentation


🌟 Features

πŸ€– AI-Powered Generation

Leverages GPT-4.1 to create comprehensive end-to-end tests from natural language scenarios and structured context.

πŸ” Iterative Workflow

Tests are automatically generated, executed, and refined until they pass successfully.

🧱 Page Object Model

Implements scalable POM design pattern for maintainable and reusable test architecture.

πŸ“Š Rich Visual Reports

Integrated Allure Reports provide interactive dashboards with detailed test steps and visualizations.

πŸ”§ CI/CD Ready

Seamlessly integrates with Jenkins pipelines for automated test execution and report generation.

πŸ’‘ GitHub Copilot Support

Enhanced with Copilot Agent Mode for intelligent test debugging and code suggestions.


🎯 What Makes This Special?

graph LR
    A[πŸ“ Scenario Input] --> B[πŸ€– AI Processing]
    B --> C[🎭 Test Generation]
    C --> D[▢️ Execution]
    D --> E{βœ… Pass?}
    E -->|No| F[πŸ”§ Refine]
    F --> C
    E -->|Yes| G[πŸ“Š Allure Report]
    style A fill:#4ade80
    style G fill:#3b82f6
    style E fill:#f59e0b
Loading

πŸš€ Quick Start

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

Tool Version Purpose
πŸ“¦ Node.js LTS (18+) Runtime environment
🧢 npm/Yarn Latest Package management
πŸ’» VS Code Latest IDE with AI extensions
🎭 Playwright Latest Browser automation
🧠 GitHub Copilot Optional AI-powered assistance

⚑ Installation

1️⃣ Clone the Repository

git clone https://github.com/your-username/playwright-mcp-automation.git
cd playwright-mcp-automation

2️⃣ Install Dependencies

npm install
# or
yarn install

3️⃣ Install Playwright Browsers

npx playwright install

4️⃣ Install Allure Dependencies

npm install -D allure-playwright allure-commandline

βš™οΈ Configuration

Update your playwright.config.ts:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  reporter: [
    ['list'],
    ['html', { open: 'never' }],
    ['allure-playwright', {
      detail: true,
      outputFolder: 'allure-results',
      suiteTitle: false,
    }],
  ],
  use: {
    trace: 'on-first-retry',
  },
});

πŸ§ͺ Running Tests

▢️ Execute Tests

npx playwright test

This generates raw test data in the allure-results/ directory

πŸ“Š Generate Allure Report

npx allure generate allure-results --clean -o allure-report

🌐 View Interactive Report

npx allure open allure-report

πŸ€– AI-Powered Test Generation

🧠 How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  1️⃣  Provide Scenario + Test Context           β”‚
β”‚  2️⃣  MCP Tools Inspect & Interact              β”‚
β”‚  3️⃣  Generate Playwright Tests (POM)           β”‚
β”‚  4️⃣  Save to /tests/ & Execute                 β”‚
β”‚  5️⃣  Refine Until Tests Pass βœ…                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’¬ Example Prompt

Navigate to http://www.automationpractice.pl/index.php
Search for "T-shirts"
Verify "Faded short sleeve T-shirts" is in the results

πŸ”„ Automated Execution Cycle

  1. Load Context - MCP loads test requirements and page structures
  2. Generate Steps - GPT-4.1 creates test steps using POM pattern
  3. Execute - Test runs automatically with Playwright
  4. Iterate - AI refines failing tests until success βœ…

πŸ’‘ Using GitHub Copilot Agent Mode

Supercharge your testing workflow with GitHub Copilot:

πŸ“¦ Setup

  1. Install GitHub Copilot and Copilot Chat extensions in VS Code
  2. Enable Agent Mode for autonomous assistance

🎯 Powerful Prompts

πŸ”Ή Generate a Playwright test for login using POM
πŸ”Ή Help debug why the test is failing
πŸ”Ή Refactor this test to use async/await properly
πŸ”Ή Add assertions for error handling

Copilot analyzes your context and provides intelligent suggestions and fixes!


πŸ—οΈ CI/CD Integration

πŸ”§ Jenkins Setup

Prerequisites Checklist

  • βœ… Jenkins server running
  • βœ… Node.js & npm installed on build agents
  • βœ… Playwright browsers configured
  • βœ… Allure CLI available

πŸ“¦ Required Jenkins Plugins

Navigate to Manage Jenkins β†’ Plugins β†’ Available:

  • βœ… Allure Jenkins Plugin
  • βœ… NodeJS Plugin

🧰 Configure Global Tools

NodeJS Configuration:

  1. Go to Manage Jenkins β†’ Global Tool Configuration
  2. Under NodeJS, add version (e.g., NodeJS 18)
  3. Check "Install automatically"

Allure CLI Configuration:

  1. Download and unzip Allure CLI
  2. Add bin/ folder to Jenkins agent PATH

🎬 Create Freestyle Job

  1. New Item β†’ Freestyle project
  2. Name: Playwright-E2E-Tests
  3. Source Code Management: Git
    • Repository URL: https://github.com/your-username/your-repo-name.git
  4. Build Environment:
    • βœ”οΈ Provide Node & npm bin folder to PATH
    • Select configured NodeJS version
  5. Build Steps (Execute Shell/Batch):
    npm install
    npx playwright install
    npx playwright test --reporter=line,allure-playwright
  6. Post-Build Action: Allure Report
    • Path to results: allure-results

πŸ“Š Jenkins Pipeline (Jenkinsfile)

pipeline {
    agent any
    
    tools {
        nodejs 'NodeJS 18' // Match Jenkins Global Tool Configuration
    }
    
    environment {
        // Optional: Add Allure path if installed manually
        PATH = "${env.PATH};C:\\allure-commandline\\bin"
    }
    
    stages {
        stage('πŸ“¦ Install Dependencies') {
            steps {
                echo 'Installing dependencies...'
                bat 'npm install'
                bat 'npx playwright install'
            }
        }
        
        stage('πŸ§ͺ Run Playwright Tests') {
            steps {
                echo 'Running Playwright tests with Allure reporter...'
                bat 'npx playwright test --reporter=line,allure-playwright'
            }
        }
        
        stage('πŸ“Š Generate Allure Report') {
            steps {
                echo 'Generating Allure HTML Report...'
                bat 'npx allure generate allure-results --clean -o allure-report'
            }
        }
    }
    
    post {
        always {
            echo 'Publishing Allure Report...'
            allure includeProperties: false,
                   jdk: '',
                   reportBuildPolicy: 'ALWAYS',
                   results: [[path: 'allure-results']]
        }
    }
}

πŸ’‘ Note: Use bat for Windows agents, sh for Linux/macOS agents

πŸš€ Pipeline Setup in Jenkins

  1. Create new Pipeline project
  2. Configure Pipeline:
    • Choose "Pipeline script from SCM"
    • SCM: Git
    • Repository URL: Your GitHub repo
    • Script Path: Jenkinsfile (case-sensitive)
  3. Save and click Build Now

βœ… Example Implementation

πŸ” Test Scenario

Goal: Search for a product on automationpractice.pl

Steps:

  1. 🧭 Navigate to homepage
  2. πŸ”Ž Search for "T-shirts"
  3. βœ… Validate "Faded short sleeve T-shirts" appears

Implementation: Built using Page Object Model with AI-generated test logic


πŸ“ Project Structure

playwright-mcp-automation/
β”œβ”€β”€ πŸ“‚ tests/              # Test files (AI-generated)
β”œβ”€β”€ πŸ“‚ pages/              # Page Object Models
β”œβ”€β”€ πŸ“‚ allure-results/     # Raw test results
β”œβ”€β”€ πŸ“‚ allure-report/      # Generated HTML reports
β”œβ”€β”€ πŸ“„ playwright.config.ts
β”œβ”€β”€ πŸ“„ Jenkinsfile
β”œβ”€β”€ πŸ“„ package.json
└── πŸ“„ README.md

πŸ“š Documentation

πŸ”— Useful Resources

Resource Link
🎭 Playwright Docs playwright.dev
πŸ“Š Allure Reports docs.qameta.io/allure
πŸ€– GitHub Copilot github.com/features/copilot
πŸ”§ Jenkins jenkins.io

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • 🎭 Playwright Team for the amazing testing framework
  • πŸ“Š Allure Framework for beautiful reports
  • πŸ€– OpenAI for GPT-4.1 capabilities
  • πŸ’» GitHub Copilot for AI-powered assistance

⭐ Star this repository if you find it helpful!

Made with ❀️ and πŸ€– AI

⬆ Back to Top

About

πŸš€ E2E Automation Framework using Playwright, TypeScript, and Allure Reporting. Integrates MCP server and dynamic test context loading for intelligent test generation and execution.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages