
Cypress Test Generator
Automatically generates Cypress Page Object Model classes by scraping web pages and extracting DOM elements with proper selectors and interaction methods.
Automates Cypress test generation by analyzing web pages with Puppeteer to extract DOM elements and generate structured page object models with appropriate selectors and test patterns for end-to-end test automation.
What it does
- Scrape web pages with Puppeteer
- Extract DOM elements and selectors
- Generate TypeScript Page Object classes
- Create interaction methods for buttons and inputs
- Parse HTML with element type detection
- Generate getter methods for elements
Best for
About Cypress Test Generator
Cypress Test Generator is a community-built MCP server published by jprealini that provides AI assistants with tools and capabilities via the Model Context Protocol. Automate Cypress test creation: analyze pages with Puppeteer to extract DOM elements and generate page object models, se It is categorized under browser automation, search web.
How to install
You can install Cypress Test Generator in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
License
Cypress Test Generator is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
MCP Cypress Page Object Generator
This MCP server automatically generates Cypress Page Object classes for any web page provided.
NPM package:
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.)
Sample prompt:
Create a page object file using the following url: https://www.saucedemo.com/
Generated Output
The server generates:
1. Page Object Class ({ClassName}.ts)
export class ExampleComLoginPage {
// Private elements
#elements = {
button_login: () => cy.get('#login-button'),
input_username: () => cy.get('input[name="username"]'),
link_home: () => cy.contains('a', 'Home')
}
// Public getters
get ButtonLogin() { return this.#elements.button_login() }
get InputUsername() { return this.#elements.input_username() }
get LinkHome() { return this.#elements.link_home() }
// Interaction methods
clickButtonLogin() { return this.#elements.button_login().click() }
typeInputUsername(text: string) { return this.#elements.input_username().type(text) }
clickLinkHome() { return this.#elements.link_home().click() }
}
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
Installation
Follow standard procedures to install an MCP in the client of your choice
Usage
-
Start the server:
node index.js -
Use with an MCP client: The server exposes a
generatePageObjectFiletool that accepts a URL parameter.Example tool call:
{ "method": "tools/call", "params": { "name": "generatePageObjectFile", "arguments": { "url": "https://example.com/login" } } } -
Response format: The server returns both the Page Object class:
// ===== PAGE OBJECT CLASS ===== // Save this as: ExampleComLoginPage.ts export class ExampleComLoginPage { ... }
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 function in index.js.
Troubleshooting: Updating to the Latest MCP Version
If you are intending to update to the latest version of this MCP server package but the new version is not being pulled by npm, try this:
- Clear the NPM cache and reinstall the package:
npm cache clean --force npm install @jprealini/cypress-mcp@latest --save-dev - If using a lockfile (
package-lock.jsonoryarn.lock), delete it and run:npm install - For global installs, update globally:
npm install -g @jprealini/cypress-mcp@latest - Verify the installed version:
npm list @jprealini/cypress-mcp
These steps ensure consumers always get the latest published MCP version and avoid issues with cached or locked old versions.
Example: Generated Page Object Format (saucedemo.com)
Below is an example of the expected Page Object format generated by MCP for saucedemo.com:
export class Swag_labsPage {
// Private elements
#elements = {
inputUsername: () => cy.get('[data-test="username"]'),
inputPassword: () => cy.get('[data-test="password"]'),
inputLoginButton: () => cy.get('[data-test="login-button"]')
}
// Element meta (currently not used for bulk actions)
// Public getters
get inputUsername() { return this.#elements.inputUsername() }
get inputPassword() { return this.#elements.inputPassword() }
get inputLoginButton() { return this.#elements.inputLoginButton() }
// Value/State getters
getValueInputUsername() { return this.#elements.inputUsername().invoke('val') }
getValueInputPassword() { return this.#elements.inputPassword().invoke('val') }
getTextInputLoginButton() { return this.#elements.inputLoginButton().invoke('text') }
// Interaction methods (per-element actions)
typeInputUsername(text) { return this.#elements.inputUsername().type(text) }
clearInputUsername() { return this.#elements.inputUsername().clear() }
typeInputPassword(text) { return this.#elements.inputPassword().type(text) }
clearInputPassword() { return this.#elements.inputPassword().clear() }
clickInputLoginButton() { return this.#elements.inputLoginButton().click() }
}
This format follows one of the mostly used page object standards, using data attributes for selectors, private element encapsulation, public getters, value/state getters, and interaction methods for each element.
If you need or expect a different pattern, you can generate this base structure using this MCP, and then use your own instruction set to edit it to fit your needs, using a prompt like:
Create a page object file using the following url: https://www.saucedemo.com/ and after creating it, edit it to meet the requirements described in my instructions.md file
Alternatives
Related Skills
Browse all skillsBrowser automation with persistent page state. Use when users ask to navigate websites, fill forms, take screenshots, extract web data, test web apps, or automate browser workflows. Trigger phrases include "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", "test the website", "log into", or any browser interaction request.
"Browser automation QA testing skill. Systematically tests web applications for functionality, security, and usability issues. Reports findings by severity (CRITICAL/HIGH/MEDIUM/LOW) with immediate alerts for critical failures."
Automate web browser interactions using natural language via CLI commands. Use when the user asks to browse websites, navigate web pages, extract data from websites, take screenshots, fill forms, click buttons, or interact with web applications. Triggers include "browse", "navigate to", "go to website", "extract data from webpage", "screenshot", "web scraping", "fill out form", "click on", "search for on the web". When taking actions be as specific as possible.
Complete browser automation with Playwright. Auto-detects dev servers, writes clean test scripts to /tmp. Test pages, fill forms, take screenshots, check responsive design, validate UX, test login flows, check links, automate any browser task. Use when user wants to test websites, automate browser interactions, validate web functionality, or perform any browser-based testing.
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.
Production-grade Playwright testing toolkit. Use when the user mentions Playwright tests, end-to-end testing, browser automation, fixing flaky tests, test migration, CI/CD testing, or test suites. Generate tests, fix flaky failures, migrate from Cypress/Selenium, sync with TestRail, run on BrowserStack. 55 templates, 3 agents, smart reporting.