Playwright MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Playwright MCPRun a login test on the OrangeHRM demo site and show me the result"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ญ Playwright MCP - AI-Powered Test Automation (OrangeHRM)
A Proof of Concept project demonstrating AI-powered browser test automation using Playwright integrated with the Model Context Protocol (MCP). Tests are written in TypeScript using the Page Object Model (POM) design pattern, targeting the OrangeHRM demo application.
๐ Table of Contents
Related MCP server: MCP Playwright Server
๐ฏ Overview
This project showcases how AI + Playwright can automate browser testing using plain English prompts via the Model Context Protocol (MCP). Instead of writing every line of automation code manually, you describe what you want to test in natural language, and AI helps generate and execute the automation.
Key Concepts
Component | Role | Analogy |
LLM (Large Language Model) | Understands requests & generates instructions | ๐ง Brain |
Agent | Executes tasks automatically | โก Doer |
MCP (Model Context Protocol) | Connects AI with real tools (browsers, APIs, etc.) | ๐ Translator |
๐ Architecture
Plain English Prompt
โ
โผ
Large Language Model (LLM)
โ
Generates Instructions
โ
โผ
AI Agent
โ
Executes the Instructions
โ
โผ
Model Context Protocol (MCP)
โ
Connects to Real Applications
โ
โผ
Playwright + Browser
โ
โผ
Browser Automation๐ป Tech Stack
Technology | Purpose |
Playwright ^1.60 | Browser automation framework |
Programming language | |
AI-to-tool communication protocol | |
CSV parsing for data-driven tests | |
Node.js | Runtime environment |
๐ Project Structure
โโโ ๐ pages/ # Page Object Model classes
โ โโโ LoginPage.ts # Login page locators & actions
โ โโโ PimPage.ts # PIM module locators & actions
โ
โโโ ๐ tests/ # Test specifications
โ โโโ example.spec.ts # Sample Playwright test
โ โโโ orangehrm-login-data-driven.spec.ts # Data-driven login (inline)
โ โโโ orangehrm-login-data-driven-csv.spec.ts # Data-driven login (CSV)
โ โโโ orangehrm-logout.spec.ts # Logout flow test
โ โโโ orangehrm-admin-system-users.spec.ts # Admin module test
โ โโโ orangehrm-buzz-post.spec.ts # Buzz social feed test
โ โโโ pim-search.spec.ts # PIM employee search
โ โโโ add-employee.spec.ts # Add employee (POM)
โ
โโโ ๐ test_data/ # Test data files
โ โโโ loginData.csv # CSV test data for login
โ
โโโ ๐ playwright-report/ # HTML test reports
โโโ ๐ test-results/ # Test execution artifacts
โ
โโโ ๐ playwright.config.ts # Playwright configuration
โโโ ๐ package.json # Dependencies & scripts
โโโ ๐ README.md # This file
โ
โโโ ๐ Playwright_MCP_Guide.md # Detailed MCP concepts guide
โโโ ๐ PlaywrightMCP_Vs_CLI.md # MCP vs CLI comparison
โโโ ๐ playwright-context.md # MCP test generator context
โโโ ๐ playwright-context-pom.md # MCP POM test generator context
โโโ ๐ prompts.md # Sample AI prompts used
โโโ ๐ notes.md # Architecture & concept notes๐งช Test Scenarios
Test File | Description | Pattern |
| Login validation with inline data (valid + invalid credentials) | Data-Driven |
| Login validation using CSV data source | Data-Driven (CSV) |
| Login, logout, and verify redirect to login page | Linear |
| Navigate to Admin โ verify System Users page | Linear |
| Post a message on Buzz feed and verify it appears | Linear |
| Search employees by name in PIM module | Linear |
| Add a new employee using Page Object Model | POM |
| Default Playwright sample test | Linear |
๐ Getting Started
Prerequisites
Installation
# Clone the repository
git clone https://github.com/pavanoltraining/POC_Playwright_MCP_orangehrm.git
# Navigate to the project directory
cd POC_Playwright_MCP_orangehrm
# Install dependencies
npm install
# Install Playwright browsers
npx playwright install chromiumโถ๏ธ Running Tests
Run all tests
npx playwright testRun a specific test file
npx playwright test tests/orangehrm-login-data-driven.spec.tsRun tests in UI mode
npx playwright test --uiView HTML report
npx playwright show-reportRun with debug mode
npx playwright test --debug๐งฉ Page Object Model
The project uses the Page Object Model (POM) design pattern for maintainable and reusable test code.
Example: LoginPage.ts
export class LoginPage {
readonly usernameInput = page.getByPlaceholder("Username");
readonly passwordInput = page.getByPlaceholder("Password");
readonly loginButton = page.getByRole("button", { name: "Login" });
async login(username: string, password: string) {
await this.usernameInput.fill(username);
await this.passwordInput.fill(password);
await this.loginButton.click();
}
}Example: PimPage.ts
export class PimPage {
async navigateToPim() {
/* ... */
}
async openAddEmployee() {
/* ... */
}
async addEmployee(firstName: string, lastName: string) {
/* ... */
}
}๐ Data-Driven Testing
Inline Data-Driven
Tests login with multiple credentials defined inline:
Username | Password | Expected Result |
Admin | admin123 | Dashboard |
fakeuser | fakepass | Invalid credentials |
ESSUser1 | ess123 | Invalid credentials |
CSV Data-Driven
Tests read test cases from test_data/loginData.csv:
Username,Password,Expected
Admin,admin123,Dashboard
fakeuser,fakepass,Invalid credentials
ESSUser1,ess123,Invalid credentials๐ค Playwright MCP vs Playwright CLI
Feature | Playwright CLI | Playwright MCP |
Purpose | Command-line tool for Playwright | AI bridge between LLM and Playwright |
Used By | Developers & Testers | AI Agents |
Input | Terminal commands | Natural language prompts |
Browser Control | Directly through Playwright scripts | Through AI + MCP Server |
Requires Coding | Yes | Minimal coding |
Generates Code | No | Yes (AI-generated) |
Executes Tests | Yes | Yes |
Uses Accessibility Tree | No | Yes |
Supports AI Automation | No | Yes |
Best For | Traditional automation | AI-powered automation |
๐ Resources
๐ License
This project is for educational and demonstration purposes only.
Built with โค๏ธ using Playwright + MCP + AI
This server cannot be deployed
Maintenance
Related MCP Connectors
Browser-based QA for AI-built software. Test pages with real browsers via agents.
Agentic testing: HyperExecute jobs, test failure triage, SmartUI visual diffs, a11y audits
Direct access to Cypress tests results and accessibility reports in your AI workflow.
Hosted browser for AI agents: screenshots, post-JS DOM, console, WCAG. No install, no API key.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables browser automation and web page interaction through Playwright's accessibility tree, allowing LLMs to navigate, fill forms, click elements, and extract content without requiring vision models or screenshots.4,633,135 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to control web browsers through Playwright automation, providing 50+ tools for navigation, interaction, testing, accessibility audits, and visual testing across Chromium, Firefox, and WebKit.6 npmMIT
- FlicenseNot gradedqualityCmaintenanceEnables AI assistants to execute browser automation, perform QA tasks, and generate test code through natural language commands using Playwright.5-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to drive Playwright-based browser automation for UI testing, returning JSON/HTML reports with screenshots without server-side LLM or test scripts.MIT