Playwright Visual Test
Run automated visual regression tests to ensure UI consistency across different viewport sizes. Capture screenshots and generate comparison reports to easily identify visual discrepancies. Integrate seamlessly with the MCP protocol for enhanced testing capabilities.
Installation
Installing for Claude Desktop
Option 1: One-Command Installation
npx mcpbar@latest install pengqiAngus/playwright-mcp -c claudeThis command will automatically install and configure the Playwright Visual Test MCP server for your selected client.
Option 2: Manual Configuration
Run the command below to open your configuration file:
npx mcpbar@latest edit -c claudeAfter opening your configuration file, copy and paste this configuration:
View JSON configuration
{
"mcpServers": {
"Playwright Visual Test": {
"command": "npx",
"args": [
"-y",
"@anguske/mcp-playwright-visual-test"
],
"env": {
"AUTO_LOGIN_USER": "${input:auto_login_user}",
"AUTO_LOGIN_PASS": "${input:auto_login_pass}",
"AUTO_LOGIN_URL": "${input:auto_login_url}"
}
}
}
}@anguske/playwright-visual-test
A visual regression testing tool based on Playwright, supporting UI screenshot comparison and automated testing.
Installation
npm install @anguske/playwright-visual-test
# or
yarn add @anguske/playwright-visual-test
# or
pnpm add @anguske/playwright-visual-test
Features
- Support for multiple viewport size testing
- Configurable comparison threshold
- Support for ignoring dynamic content areas
- Automatic comparison report generation
- Integration with MCP protocol
API Documentation
runTest(options)
Main test function, accepts the following parameters:
url: Target page URLviewport: Viewport size configuration{ width: number, height: number }waitForSelector?: Optional, wait for specific element to appearignoreSelectors?: Optional, array of selectors to ignorethreshold?: Optional, pixel comparison threshold (0-1)
License
MIT
MCP Playwright Visual Test Tool Configuration Guide
In mcp.json, you can configure the Playwright visual test tool as follows:
{
"mcp-playwright": {
"command": "npx",
"args": [
"-y",
"@anguske/mcp-playwright-visual-test"
],
"env": {
// Auto login configuration
"AUTO_LOGIN_USERNAME": "your-username",
"AUTO_LOGIN_PASSWORD": "your-password",
"AUTO_LOGIN_USERNAME_SELECTOR": "#userNameSignIn",
"AUTO_LOGIN_PASSWORD_SELECTOR": "#passwordSignIn",
"AUTO_LOGIN_SUBMIT_SELECTOR": "input[type=\"submit\"]",
"AUTO_LOGIN_SUCCESS_SELECTOR": "", // Optional, element selector after successful login
"AUTO_LOGIN_URL_PATTERN": "login|signin|auth", // Login page URL match pattern
// Visual test configuration
"TEST_SELECTOR": "", // Optional, selector for element to screenshot
"TEST_WAIT_FOR_SELECTOR": "", // Optional, wait for specific element
"TEST_WAIT_TIMEOUT": 10000, // Optional, wait timeout in milliseconds
"TEST_THRESHOLD": 20, // Optional, pixel comparison threshold (0-100)
"TEST_IGNORE_SELECTORS": ".dynamic-content,.ads", // Optional, selectors to ignore, comma separated
"TEST_VIEWPORT_WIDTH": 1440, // Optional, viewport width, default 1280
"TEST_VIEWPORT_HEIGHT": 800, // Optional, viewport height, default 720
// Project configuration
"PROJECT_ROOT": "D:/myProject/quickstart-resources/weather-server-typescript" // Project root path
}
}
}
Configuration Details
Auto Login Configuration
AUTO_LOGIN_USERNAME: Login usernameAUTO_LOGIN_PASSWORD: Login passwordAUTO_LOGIN_USERNAME_SELECTOR: Username input field selectorAUTO_LOGIN_PASSWORD_SELECTOR: Password input field selectorAUTO_LOGIN_SUBMIT_SELECTOR: Login button selectorAUTO_LOGIN_SUCCESS_SELECTOR: Element selector after successful login (optional)AUTO_LOGIN_URL_PATTERN: Login page URL match pattern for auto-detecting login page redirects
Visual Test Configuration
TEST_SELECTOR: Selector for element to screenshot, captures entire page if not setTEST_WAIT_FOR_SELECTOR: Wait for specific element before taking screenshotTEST_WAIT_TIMEOUT: Timeout for waiting for element (milliseconds)TEST_THRESHOLD: Pixel difference threshold for image comparison (0-100), default 100TEST_IGNORE_SELECTORS: List of selectors to ignore during comparison, comma separatedTEST_VIEWPORT_WIDTH: Browser viewport width, default 1280TEST_VIEWPORT_HEIGHT: Browser viewport height, default 720
Project Configuration
PROJECT_ROOT: Absolute path to project root directory for storing screenshots and files
Notes
- All configuration items are optional, but it's recommended to configure essential login information and viewport size
- Screenshots will be saved in the
screenshotsfolder in the project root directory - Comparison results will generate three files:
current.png: Current test screenshotbaseline.png: Baseline screenshotdiff.png: Difference comparison image
- On first run, the current screenshot will automatically be set as the baseline image
Details:
Stars
0Forks
0Last commit
7 months agoRepository age
8 months
Auto-fetched from GitHub .
MCP servers similar to Playwright Visual Test:
Stars
Forks
Last commit
Stars
Forks
Last commit
Stars
Forks
Last commit