This MCP server automatically generates Cypress Page Object classes and comprehensive test suites for any web page by analyzing its structure.
Core Capabilities:
Web Scraping & Analysis: Uses Puppeteer to fetch and render web pages (including dynamic content) and Cheerio to parse HTML elements
Page Object Generation: Creates TypeScript classes with private element locators, public getters, interaction methods (click, type, select, clear), and workflow methods for common patterns like login and search
Comprehensive Test Generation: Produces test suites covering positive tests (interactions, workflows, validation), negative tests (error handling, edge cases), and additional tests (accessibility, performance, responsive design, security)
Element Support: Handles buttons, input fields, links, select dropdowns, textareas, and forms
Workflow Detection: Intelligently identifies patterns like login forms, search forms, and navigation flows to generate appropriate methods and tests
File Creation: Directly writes Page Object and test files into your Cypress project structure with custom naming and workspace path options
Available Tools:
generateLocator: Returns generated Page Object and test suite code for a given URLcreateCypressFiles: Creates and saves files directly into your Cypress project with configuration options
Uses Cheerio to parse HTML and extract element information from web pages for test generation
Generates complete Cypress Page Object classes and comprehensive test suites for web pages, including positive and negative test cases, workflow tests, and accessibility tests
Uses Puppeteer for web scraping and page rendering to fetch and analyze web pages before generating tests
Creates TypeScript Page Object classes with private element locators, public getter methods, and interaction methods
Utilizes Zod for schema validation in the generated test suites
MCP Cypress Page Object & Test Generator
This MCP (Model Context Protocol) server automatically generates complete Cypress Page Object classes AND comprehensive test suites for any web page.
Features
Web Scraping: Uses Puppeteer to fetch and render web pages
HTML Parsing: Uses Cheerio to parse HTML and extract element information
Page Object Generation: Creates complete TypeScript Page Object classes with:
Private element locators
Public getter methods
Interaction methods (click, type, select, etc.)
Workflow methods for common test scenarios
Test Suite Generation: Creates comprehensive Cypress test files with:
Positive test cases for all elements
Negative test cases for error handling
Workflow tests for common scenarios
Accessibility, performance, and edge case tests
Related MCP server: QASE MCP Server
Generated Output
The server generates two files:
1. Page Object Class ({ClassName}.ts)
2. Test Suite ({ClassName}.cy.ts)
Test Categories Generated
✅ Positive Test Cases
Element Interactions: Click, type, clear, check/uncheck for all detected elements
Workflow Tests: Login, search, navigation workflows
Form Validation: Successful form submissions
Element Visibility: All elements are visible and accessible
❌ Negative Test Cases
Error Handling: Network errors, server errors, slow connections
Validation Errors: Empty fields, invalid formats, required field validation
Edge Cases: Large inputs, special characters, unicode text
Accessibility: ARIA labels, keyboard navigation
🔧 Additional Test Types
Performance Tests: Load times, rapid interactions
Responsive Tests: Different viewport sizes
Accessibility Tests: ARIA compliance, keyboard navigation
Security Tests: Input sanitization, XSS prevention
Element Types Supported
Buttons: Click interactions with validation
Input Fields: Type, clear, check/uncheck (for checkboxes/radio)
Links: Click interactions with navigation verification
Select Dropdowns: Select options with validation
Textareas: Type and clear with content verification
Forms: Submit interactions with success/error handling
Workflow Detection
The server intelligently detects common patterns and generates appropriate tests:
Login Forms: Username/password validation, error handling
Search Forms: Query validation, results verification
Navigation: Home links, breadcrumbs, menu items
Form Submissions: Success states, validation errors
Installation
Usage
Start the server:
npx tsx main.tsUse with an MCP client: The server exposes a
generateLocatortool that accepts a URL parameter.Example tool call:
{ "method": "tools/call", "params": { "name": "generateLocator", "arguments": { "url": "https://example.com/login" } } }Response format: The server returns both the Page Object class and test suite:
// ===== PAGE OBJECT CLASS ===== // Save this as: ExampleComLoginPage.ts export class ExampleComLoginPage { ... } // ===== CYPRESS TESTS ===== // Save this as: ExampleComLoginPage.cy.ts describe('ExampleComLoginPage Tests', () => { ... }
Example Usage in Tests
Dependencies
@modelcontextprotocol/sdk: MCP server implementationpuppeteer: Web scraping and page renderingcheerio: HTML parsing and element selectionzod: Schema validationtypescript: Type safety
Error Handling
The server includes comprehensive error handling for:
Invalid URLs
Network connectivity issues
Page loading failures
HTML parsing errors
Browser Configuration
The server uses Puppeteer with the following settings:
Headless mode for server environments
No-sandbox mode for containerized deployments
Network idle waiting for dynamic content
Contributing
To add support for new element types, interaction methods, or test patterns, modify the generatePageObjectClass and generateCypressTests functions in main.ts.