Harness the power of GPT-4.1 to generate, execute, and refine Playwright tests automatically
Features β’ Quick Start β’ CI/CD β’ Documentation
|
Leverages GPT-4.1 to create comprehensive end-to-end tests from natural language scenarios and structured context. Tests are automatically generated, executed, and refined until they pass successfully. Implements scalable POM design pattern for maintainable and reusable test architecture. |
Integrated Allure Reports provide interactive dashboards with detailed test steps and visualizations. Seamlessly integrates with Jenkins pipelines for automated test execution and report generation. Enhanced with Copilot Agent Mode for intelligent test debugging and code suggestions. |
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
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 |
1οΈβ£ Clone the Repository
git clone https://github.com/your-username/playwright-mcp-automation.git
cd playwright-mcp-automation2οΈβ£ Install Dependencies
npm install
# or
yarn install3οΈβ£ Install Playwright Browsers
npx playwright install4οΈβ£ Install Allure Dependencies
npm install -D allure-playwright allure-commandlineUpdate 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',
},
});npx playwright testThis generates raw test data in the allure-results/ directory
npx allure generate allure-results --clean -o allure-reportnpx allure open allure-reportβββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Navigate to http://www.automationpractice.pl/index.php
Search for "T-shirts"
Verify "Faded short sleeve T-shirts" is in the results
- Load Context - MCP loads test requirements and page structures
- Generate Steps - GPT-4.1 creates test steps using POM pattern
- Execute - Test runs automatically with Playwright
- Iterate - AI refines failing tests until success β
Supercharge your testing workflow with GitHub Copilot:
- Install GitHub Copilot and Copilot Chat extensions in VS Code
- Enable Agent Mode for autonomous assistance
πΉ 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!
- β Jenkins server running
- β Node.js & npm installed on build agents
- β Playwright browsers configured
- β Allure CLI available
Navigate to Manage Jenkins β Plugins β Available:
- β Allure Jenkins Plugin
- β NodeJS Plugin
NodeJS Configuration:
- Go to Manage Jenkins β Global Tool Configuration
- Under NodeJS, add version (e.g., NodeJS 18)
- Check "Install automatically"
Allure CLI Configuration:
- Download and unzip Allure CLI
- Add
bin/folder to Jenkins agent PATH
- New Item β Freestyle project
- Name:
Playwright-E2E-Tests - Source Code Management: Git
- Repository URL:
https://github.com/your-username/your-repo-name.git
- Repository URL:
- Build Environment:
- βοΈ Provide Node & npm bin folder to PATH
- Select configured NodeJS version
- Build Steps (Execute Shell/Batch):
npm install npx playwright install npx playwright test --reporter=line,allure-playwright - Post-Build Action: Allure Report
- Path to results:
allure-results
- Path to results:
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
batfor Windows agents,shfor Linux/macOS agents
- Create new Pipeline project
- Configure Pipeline:
- Choose "Pipeline script from SCM"
- SCM: Git
- Repository URL: Your GitHub repo
- Script Path:
Jenkinsfile(case-sensitive)
- Save and click Build Now
Goal: Search for a product on automationpractice.pl
Steps:
- π§ Navigate to homepage
- π Search for "T-shirts"
- β Validate "Faded short sleeve T-shirts" appears
Implementation: Built using Page Object Model with AI-generated test logic
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
| Resource | Link |
|---|---|
| π Playwright Docs | playwright.dev |
| π Allure Reports | docs.qameta.io/allure |
| π€ GitHub Copilot | github.com/features/copilot |
| π§ Jenkins | jenkins.io |
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- π Playwright Team for the amazing testing framework
- π Allure Framework for beautiful reports
- π€ OpenAI for GPT-4.1 capabilities
- π» GitHub Copilot for AI-powered assistance