### Getting Started Prompts Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Commonly used prompts for initiating basic, responsive, and orientation-based tests. ```text Navigate to [your-site.com] and test on iPhone 13 ``` ```text Test [your-site.com] on iPhone 13, iPad Pro 11, and Desktop Chrome ``` ```text Test [your-site.com] on iPhone 13 in both portrait and landscape ``` -------------------------------- ### Install Dependencies Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/local-setup/Installation.mdx Navigate to the project directory and install required packages. ```bash cd mcp-playwright npm install ``` -------------------------------- ### Start Playwright MCP Server Source: https://github.com/executeautomation/mcp-playwright/blob/main/examples/http-mode-example.md Use npx or npm to install and start the Playwright MCP Server on a specified port. Ensure the port is available before starting. ```bash # Using npx npx @executeautomation/playwright-mcp-server --port 8931 ``` ```bash # Or after global installation npm install -g @executeautomation/playwright-mcp-server playwright-mcp-server --port 8931 ``` -------------------------------- ### Install Dependencies and Build Project Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Install production dependencies and build the project before creating the Docker image to ensure a minimal image size. ```bash npm install --omit=dev npm run build ``` -------------------------------- ### Start the HTTP Server Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Commands to launch the Playwright MCP server in HTTP mode using npx or global installation. ```bash npx @executeautomation/playwright-mcp-server --port 8931 ``` ```bash # Install globally npm install -g @executeautomation/playwright-mcp-server # Run the server playwright-mcp-server --port 8931 ``` ```bash # Option 1: Update to latest version npx @executeautomation/playwright-mcp-server@latest --port 8931 # Option 2: Use global installation instead npm install -g @executeautomation/playwright-mcp-server playwright-mcp-server --port 8931 ``` -------------------------------- ### Run MCP Playwright Server with Automatic Browser Installation Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/release.mdx Execute the server command to automatically detect and install missing browsers on first use. No manual browser installation is required. ```bash npx @executeautomation/playwright-mcp-server ``` -------------------------------- ### Build Project Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/local-setup/Installation.mdx Install TypeScript and compile the project for local use. ```bash npm install --save-dev typescript npm run build npm link ``` -------------------------------- ### Navigation and Resize Execution Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Example of combining navigation and resizing commands. ```text Navigate to https://example.com and test it on iPhone 13 ``` ```javascript await playwright_navigate({ url: "https://example.com" }); await playwright_resize({ device: "iPhone 13" }); ``` -------------------------------- ### Install and Run MCP Inspector Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/local-setup/Debugging.mdx Use this command to launch the inspector with your server's entry point. ```bash npx @modelcontextprotocol/inspector node dist/index.js ``` -------------------------------- ### Test npx and Global Installation Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Commands to test both npx and global installation methods for the MCP Playwright server. It's recommended to try npx first. ```bash # Try npx first npx @executeautomation/playwright-mcp-server@latest --port 8931 # If no output, use global install npm install -g @executeautomation/playwright-mcp-server playwright-mcp-server --port 8931 ``` -------------------------------- ### Log message structure examples Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Example JSON log entries for client connection, message transmission, and disconnection events. ```json // Client connects {"level":"info","message":"Incoming request","context":{"method":"GET","path":"/mcp"}} {"level":"info","message":"SSE connection request received","context":{"endpoint":"/mcp"}} {"level":"info","message":"Transport registered","context":{"sessionId":"...","activeTransports":1}} // Client sends message {"level":"info","message":"Incoming request","context":{"method":"POST","path":"/mcp"}} {"level":"POST message received","context":{"sessionId":"...","availableTransports":[...]}} // Client disconnects {"level":"info","message":"SSE connection closed","context":{"sessionId":"...","endpoint":"/mcp"}} {"level":"info","message":"Transport unregistered","context":{"activeTransports":0}} ``` -------------------------------- ### Configure Browser Environment Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Install required browsers and set display variables for headless server environments. ```bash npx playwright install chromium export DISPLAY=:99 ``` -------------------------------- ### Testing Multiple Devices Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Device-Quick-Reference.md Example of iterating through multiple device presets and capturing screenshots for each. ```javascript await playwright_navigate({ url: "homepage" }); await playwright_resize({ device: "iPhone 13" }); await playwright_screenshot({ name: "mobile" }); await playwright_resize({ device: "iPad Pro 11" }); await playwright_screenshot({ name: "tablet" }); await playwright_resize({ device: "Desktop Chrome" }); await playwright_screenshot({ name: "desktop" }); ``` -------------------------------- ### Start Server with Docker Compose Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Start the Playwright MCP server using Docker Compose. This command assumes a `docker-compose.yml` file is present. ```bash docker compose run --rm playwright-mcp ``` -------------------------------- ### Install Playwright MCP Server via Smithery Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/intro.mdx Installs the Playwright MCP Server package for Claude Desktop using the Smithery CLI. Ensure you have npx installed. ```bash npx @smithery/cli install @executeautomation/playwright-mcp-server --client claude ``` -------------------------------- ### Install Playwright MCP Server via MCP-GET Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/intro.mdx Installs the Playwright MCP Server package using the mcp-get tool. This is a convenient way to manage MCP installations. ```bash npx @michaellatman/mcp-get@latest install @executeautomation/playwright-mcp-server ``` -------------------------------- ### Server Output and Configuration Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Example console output showing server status, endpoints, and the required client configuration JSON. ```text ⏳ Initializing Playwright MCP Server on port 8931... 🚀 Starting Playwright MCP Server (HTTP Mode)... ============================================== Playwright MCP Server (HTTP Mode) ============================================== Listening: 127.0.0.1:8931 (localhost only) Version: 1.0.9 SECURITY: Server is bound to localhost only. Not accessible from external networks. ENDPOINTS: - SSE Stream: GET http://localhost:8931/sse - Messages: POST http://localhost:8931/messages?sessionId= - MCP (unified): GET http://localhost:8931/mcp - MCP (unified): POST http://localhost:8931/mcp?sessionId= - Health Check: GET http://localhost:8931/health CLIENT CONFIGURATION: { "mcpServers": { "playwright": { "url": "http://localhost:8931/mcp", "type": "http" } } } ============================================== Monitoring HTTP server listening on port 55123 Health check: http://localhost:55123/health Metrics: http://localhost:55123/metrics ``` -------------------------------- ### Orientation Testing Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Device-Quick-Reference.md Example of switching a device to landscape orientation. ```javascript await playwright_resize({ device: "iPhone 13" }); // Test portrait menu await playwright_resize({ device: "iPhone 13", orientation: "landscape" }); // Test landscape menu ``` -------------------------------- ### Testing a Single Device Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Device-Quick-Reference.md Example of navigating to a URL and resizing the viewport to a specific device preset. ```javascript await playwright_navigate({ url: "my-site.com" }); await playwright_resize({ device: "iPhone 13" }); ``` -------------------------------- ### Execute Build Script Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Run the provided build script to install dependencies and build the project for Docker. ```bash chmod +x docker-build.sh ./docker-build.sh ``` -------------------------------- ### Configure VS Code GitHub Copilot Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Steps to start the server and update VS Code settings for HTTP transport. ```bash playwright-mcp-server --port 8931 ``` ```json { "github.copilot.chat.mcp.servers": { "playwright": { "url": "http://localhost:8931/mcp", "type": "http" } } } ``` -------------------------------- ### Install Playwright Browsers Manually Source: https://github.com/executeautomation/mcp-playwright/blob/main/README.md Manually install Playwright browser binaries if automatic installation fails or if you prefer manual control. You can install all browsers or specific ones like Chromium, Firefox, or WebKit. ```bash npx playwright install ``` ```bash npx playwright install chromium ``` ```bash npx playwright install firefox ``` ```bash npx playwright install webkit ``` -------------------------------- ### Install Playwright MCP Server in VS Code CLI Source: https://github.com/executeautomation/mcp-playwright/blob/main/README.md Install the Playwright MCP server in VS Code using the command-line interface. ```bash code --add-mcp '{"name":"playwright","command":"npx","args":["@executeautomation/playwright-mcp-server"]}' ``` -------------------------------- ### Build and Run with Docker Compose Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Build the Docker image and then start the Playwright MCP server using Docker Compose. ```bash docker compose build docker compose run --rm playwright-mcp ``` -------------------------------- ### Progressive Testing Workflow Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Example of a multi-step responsive testing prompt and the corresponding AI execution code. ```text Test this page's responsiveness: 1. Start with mobile (iPhone 13) 2. Then tablet (iPad Pro 11) 3. Finally desktop (Desktop Chrome) Take screenshots at each size and check if the layout looks correct. ``` ```javascript // The AI executes: await playwright_navigate({ url: "https://example.com" }); await playwright_resize({ device: "iPhone 13" }); await playwright_screenshot({ name: "mobile-view" }); await playwright_resize({ device: "iPad Pro 11" }); await playwright_screenshot({ name: "tablet-view" }); await playwright_resize({ device: "Desktop Chrome" }); await playwright_screenshot({ name: "desktop-view" }); ``` -------------------------------- ### Perform HTTP GET Request Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Executes a GET request with support for authentication tokens and custom headers. ```javascript // Simple GET request await playwright_get({ url: "https://api.example.com/users" }); // GET with Bearer token await playwright_get({ url: "https://api.example.com/profile", token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }); // GET with custom headers await playwright_get({ url: "https://api.example.com/data", headers: { "X-API-Key": "your-api-key", "Accept": "application/json" } }); ``` -------------------------------- ### Custom Dimensions Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Device-Quick-Reference.md Example of setting a viewport size using specific width and height values. ```javascript await playwright_resize({ width: 1024, height: 768 }); ``` -------------------------------- ### Install Playwright MCP Server via NPM Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/intro.mdx Installs the Playwright MCP Server package globally using npm. This command can be run in any integrated terminal. ```bash npm install -g @executeautomation/playwright-mcp-server ``` -------------------------------- ### Start Codegen Session Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Initializes a recording session to capture Playwright actions and generate test files. ```javascript // Start recording session await start_codegen_session({ options: { outputPath: "/path/to/tests", testNamePrefix: "LoginTest", includeComments: true } }); // Returns: { sessionId: "uuid", options: {...}, message: "Started codegen session..." } ``` -------------------------------- ### start_codegen_session Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Starts a session to record Playwright actions and generate test files. ```APIDOC ## start_codegen_session ### Description Start a code generation session to record Playwright actions and generate test files. ### Parameters #### Request Body - **options** (object) - Required - Configuration for the session (outputPath, testNamePrefix, includeComments). ### Response #### Success Response (200) - **sessionId** (string) - The unique ID of the session. - **options** (object) - The configuration used. - **message** (string) - Status message. ``` -------------------------------- ### Debugging Device-Specific Issues Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Device-Quick-Reference.md Example of running a test sequence across multiple device sizes to isolate responsive issues. ```javascript await playwright_resize({ device: "iPhone SE" }); // Check button await playwright_resize({ device: "iPhone 13" }); // Check button await playwright_resize({ device: "iPhone 15 Pro Max" }); // Check button ``` -------------------------------- ### Start Playwright MCP Server in HTTP Mode Source: https://github.com/executeautomation/mcp-playwright/blob/main/README.md Start the Playwright MCP server as a standalone HTTP server on a specified port. This is useful for running headed browsers on systems without a display or from worker processes. ```bash # Using npx npx @executeautomation/playwright-mcp-server --port 8931 # Or after global installation playwright-mcp-server --port 8931 ``` -------------------------------- ### Manually Build Docker Image Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Build the Docker image for the Playwright MCP Server locally. Ensure dependencies are installed with `--omit=dev`. ```bash docker build -t mcp-playwright:latest . ``` -------------------------------- ### Custom Dockerfile for Browser Installation Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Create a custom Dockerfile to pre-install Playwright browsers within the Docker image, which can be useful if the default image skips browser downloads. ```dockerfile FROM mcp-playwright:latest # Install Playwright browsers RUN npx playwright install chromium --with-deps ``` -------------------------------- ### Server Debug Logs Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Example of the JSON-formatted logs generated by the server for request and session tracking. ```json {"level":"info","message":"Incoming request","context":{"method":"GET","path":"/mcp"}} {"level":"info","message":"Transport registered","context":{"sessionId":"abc-123","activeTransports":1}} {"level":"info","message":"POST message received","context":{"sessionId":"abc-123","endpoint":"/mcp"}} ``` -------------------------------- ### Start HTTP/SSE Transport Server Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/release.mdx Launches the mcp-playwright server in standalone HTTP mode with Server-Sent Events support. Ensure the specified port is available. ```bash playwright-mcp-server --port 8931 ``` -------------------------------- ### Install Playwright MCP Server with Claude Code Source: https://github.com/executeautomation/mcp-playwright/blob/main/README.md Add the Playwright MCP server using Claude's command-line interface with stdio transport. ```bash claude mcp add --transport stdio playwright npx @executeautomation/playwright-mcp-server ``` -------------------------------- ### Execute CRUD Operations Scenario Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-api/Examples.md A high-level scenario demonstrating POST, GET, PUT, and PATCH operations with token authorization. ```json // Basic POST request Perform POST operation for the URL https://api.restful-api.dev/objects with body { "name": "Apple MacBook Pro 16", "data": { "year": 2024, "price": 2499, "CPU model": "M4", "Hard disk size": "5 TB" } } And verify if the response has createdAt and id property and store the ID in a variable for future reference say variable productID // POST request with Bearer token authorization Perform POST operation for the URL https://api.restful-api.dev/objects with Bearer token "your-token-here" set in the headers { 'Content-Type': 'application/json', 'Authorization': 'Bearer your-token-here' }, and body { "name": "Secure MacBook Pro", "data": { "year": 2024, "price": 2999, "CPU model": "M4 Pro", "Hard disk size": "8 TB", "security": "enhanced" } } Perform GET operation for the created ProductID using URL https://api.restful-api.dev/objects/productID and verify the response has properties like Id, name, data Perform PUT operation for the created ProductID using URL https://api.restful-api.dev/objects/productID with body { "name": "Apple MacBook Pro 16", "data": { "year": 2025, "price": 4099, "CPU model": "M5", "Hard disk size": "10 TB", "color": "Titanium" } } And verify if the response has createdAt and id property Perform PATCH operation for the created ProductID using URL https://api.restful-api.dev/objects/productID with body { "name": "Apple MacBook Pro 19 (Limited Edition)" } And verify if the response has updatedAt property with value Apple MacBook Pro 19 (Limited Edition) ``` -------------------------------- ### Access MCP Inspector URL Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/local-setup/Debugging.mdx Navigate to this local address in your browser after starting the inspector. ```text http://localhost:5173 🚀 ``` -------------------------------- ### Analyze page text content Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Examples.md Example workflow for extracting text to perform content analysis. ```bdd Given I navigate to website "https://example.com/pricing" When I extract all visible text from the page Then I should be able to analyze the text to find pricing information And I can determine if the "Enterprise" plan mentions "custom pricing" ``` -------------------------------- ### Start Code Generation Session Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/release.mdx Initiates a code generation session to record Playwright actions. This tool allows for the conversion of real browser interactions into reusable Playwright tests. ```python start_codegen_session ``` -------------------------------- ### Get Code Generation Session Info Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Retrieves information about an active code generation session. Requires a session ID. ```javascript await get_codegen_session({ sessionId: "your-session-id" }); ``` -------------------------------- ### GET /Playwright_get Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-api/Supported-Tools.mdx Perform a GET operation on any given API request. ```APIDOC ## GET Playwright_get ### Description Perform a GET operation on any given API request. ### Parameters #### Request Body - **url** (string) - Required - URL to perform the GET operation. - **token** (string) - Optional - Bearer token for authorization. - **headers** (object) - Optional - Additional headers to include in the request. ### Response #### Success Response (200) - **statusCode** (string) - Status code of the API. ``` -------------------------------- ### Execute Login Scenario Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Examples.md Performs a standard login and navigation flow on a sample application. ```bdd Given I navigate to website http://eaapp.somee.com and click login link And I enter username and password as "admin" and "password" respectively and perform login Then click the Employee List page And click "Create New" button and enter realistic employee details to create for Name, Salary, DurationWorked, Select dropdown for Grade as CLevel and Email. ``` -------------------------------- ### Advanced Navigation with Playwright MCP Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Navigates to a URL with custom browser type (Firefox), viewport size, timeout, wait condition, and headless mode. Requires specific browser engine setup. ```javascript await playwright_navigate({ url: "https://example.com", browserType: "firefox", width: 1920, height: 1080, timeout: 60000, waitUntil: "networkidle", headless: true }); ``` -------------------------------- ### Listing and Filtering Devices Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Device-Quick-Reference.md Commands to list available device presets or filter them via the CLI. ```bash node scripts/list-devices.cjs ``` ```bash node scripts/list-devices.cjs iphone node scripts/list-devices.cjs pixel node scripts/list-devices.cjs ipad node scripts/list-devices.cjs galaxy ``` -------------------------------- ### API GET Request with Bearer Token Authentication Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/release.mdx Perform a GET request to a protected API endpoint using Bearer token authentication. Ensure the token is correctly formatted. ```javascript await playwright_get({ url: 'https://api.example.com/protected-data', token: 'your-bearer-token' }); ``` -------------------------------- ### Automated Testing Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Build the project and execute the provided test script. ```bash # Clone the repository git clone https://github.com/executeautomation/mcp-playwright.git cd mcp-playwright # Build npm run build # Run automated tests ./test-http-mode.sh ``` -------------------------------- ### GET /get_codegen_session Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Retrieves information about an active code generation session. ```APIDOC ## GET /get_codegen_session ### Description Get information about an active code generation session. ### Method GET ### Endpoint /get_codegen_session ### Request Body - **sessionId** (string) - Required - The ID of the session to retrieve. ``` -------------------------------- ### Docker Deployment Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Build and run the server within a Docker container. ```dockerfile FROM node:20 WORKDIR /app RUN npm install -g @executeautomation/playwright-mcp-server EXPOSE 8931 CMD ["playwright-mcp-server", "--port", "8931"] ``` ```bash docker build -t playwright-mcp . docker run -p 8931:8931 playwright-mcp ``` -------------------------------- ### playwright_expect_response Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Starts waiting for an HTTP response matching a specific URL pattern. ```APIDOC ## playwright_expect_response ### Description Start waiting for an HTTP response matching a URL pattern. Use with playwright_assert_response to validate responses. ### Parameters #### Request Body - **id** (string) - Required - Unique identifier for the response expectation. - **url** (string) - Required - URL pattern to match. ``` -------------------------------- ### playwright_get Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Performs an HTTP GET request with optional authentication and custom headers. ```APIDOC ## playwright_get ### Description Perform an HTTP GET request with optional authentication and custom headers. ### Parameters #### Request Body - **url** (string) - Required - The target URL. - **token** (string) - Optional - Bearer token for authentication. - **headers** (object) - Optional - Custom HTTP headers. ``` -------------------------------- ### SSE and Unified Endpoints Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Connect to the server using legacy SSE or the recommended unified MCP endpoint. ```bash curl -N http://localhost:8931/sse ``` ```bash curl -N http://localhost:8931/mcp ``` -------------------------------- ### Playwright Get Visible Text Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Supported-Tools.mdx Retrieves the visible text content of the current page. ```APIDOC ## playwright_get_visible_text ### Description Get the visible text content of the current page. ### Method GET ### Endpoint /executeautomation/mcp-playwright/playwright_get_visible_text ### Response #### Success Response (200) - **`content`** (string) - The visible text content of the current page, extracted from visible DOM elements. Hidden elements (with display:none or visibility:hidden) are excluded. ``` -------------------------------- ### Device Discovery Prompts Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Natural language prompts used to query available device configurations. ```text What iPhone models can I test on? ``` ```text Show me all available Android devices ``` ```text What desktop browser options do I have? ``` -------------------------------- ### Automate Multiple Browser Engines Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Examples.md Demonstrates switching between Firefox and WebKit engines to compare rendering. ```bdd Given I navigate to website "https://example.com" using the "firefox" browser And I take a screenshot named "firefox-example" Then I navigate to website "https://example.com" using the "webkit" browser And I take a screenshot named "webkit-example" ``` -------------------------------- ### Command-Line Interface Usage Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Run the server in stdio or HTTP mode using various CLI flags. ```bash playwright-mcp-server [OPTIONS] OPTIONS: --port Run in HTTP mode on the specified port --help, -h Show help message EXAMPLES: # Run in stdio mode (default) playwright-mcp-server # Run in HTTP mode on port 8931 playwright-mcp-server --port 8931 # Run in HTTP mode on custom port playwright-mcp-server --port 3000 ``` -------------------------------- ### Clone Repository Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/local-setup/Installation.mdx Download the source code from the official repository. ```bash git clone https://github.com/executeautomation/mcp-playwright.git ``` -------------------------------- ### Manual Dimension Prompts Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Prompts for setting specific viewport dimensions. ```text Resize to 1024x768 ``` ```text Set viewport to 800x600 ``` ```text Test at 1366x768 resolution ``` ```text Test at small tablet size: 768x1024 ``` ```text Show me the mobile breakpoint: 375x667 ``` ```text Resize to standard HD: 1920x1080 ``` -------------------------------- ### Complete Login Test Workflow Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Demonstrates a full login test automation workflow, including navigation, filling credentials, API response assertion, and cleanup. ```javascript // 1. Navigate to the login page await playwright_navigate({ url: "https://myapp.example.com/login", browserType: "chromium", headless: false }); ``` ```javascript // 2. Take initial screenshot await playwright_screenshot({ name: "login-page" }); ``` ```javascript // 3. Fill in credentials await playwright_fill({ selector: "#email", value: "user@example.com" }); ``` ```javascript await playwright_fill({ selector: "#password", value: "password123" }); ``` ```javascript // 4. Set up response expectation before clicking await playwright_expect_response({ id: "auth-response", url: "**/api/auth" }); ``` ```javascript // 5. Click login button await playwright_click({ selector: "#login-submit" }); ``` ```javascript // 6. Assert the authentication response await playwright_assert_response({ id: "auth-response", value: "token" }); ``` ```javascript // 7. Take screenshot of dashboard await playwright_screenshot({ name: "dashboard", fullPage: true }); ``` ```javascript // 8. Get page content for verification await playwright_get_visible_text({}); ``` ```javascript // 9. Close browser await playwright_close({}); ``` -------------------------------- ### Playwright Get Visible HTML Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Supported-Tools.mdx Retrieves the HTML content of the current page, with options for filtering and cleaning. ```APIDOC ## playwright_get_visible_html ### Description Get the HTML content of the current page. ### Method POST ### Endpoint /executeautomation/mcp-playwright/playwright_get_visible_html ### Parameters #### Request Body - **`selector`** (string) - Optional - CSS selector to limit the HTML to a specific container. If provided, only returns the HTML for that element. - **`removeScripts`** (boolean) - Optional, default: false - Remove all script tags from the HTML to reduce noise. - **`removeComments`** (boolean) - Optional, default: false - Remove all HTML comments to clean up the output. - **`removeStyles`** (boolean) - Optional, default: false - Remove all style tags from the HTML. - **`removeMeta`** (boolean) - Optional, default: false - Remove all meta tags from the HTML head section. - **`minify`** (boolean) - Optional, default: false - Minify the HTML output by removing extra whitespace. - **`cleanHtml`** (boolean) - Optional, default: false - Convenience option that combines removeScripts, removeComments, removeStyles, and removeMeta for a cleaner HTML output. ### Response #### Success Response (200) - **`content`** (string) - The HTML content of the current page, optionally filtered based on the provided parameters. ``` -------------------------------- ### Perform Bearer Token Authentication Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-api/Examples.md Use the token parameter to authenticate GET, POST, and DELETE requests. ```typescript // GET request with Bearer token await playwright_get({ url: 'https://api.example.com/protected-data', token: 'your-bearer-token-here' }); // POST request with Bearer token await playwright_post({ url: 'https://api.example.com/create', value: '{"name":"test"}', token: 'your-bearer-token-here' }); // DELETE request with Bearer token await playwright_delete({ url: 'https://api.example.com/resource/123', token: 'your-bearer-token-here' }); ``` -------------------------------- ### Build Docker Image with Specific Tag Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Build the Docker image and tag it with a specific version number. ```bash docker build -t mcp-playwright:1.0.6 . ``` -------------------------------- ### Get Visible HTML Content Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Retrieve the page HTML with options to clean, minify, or filter specific elements. ```javascript // Get HTML with scripts removed (default) await playwright_get_visible_html({}); // Get HTML for specific element await playwright_get_visible_html({ selector: "#main-content" }); // Get cleaned and minified HTML await playwright_get_visible_html({ cleanHtml: true, minify: true, removeComments: true, removeStyles: true, removeMeta: true }); // Keep scripts in output await playwright_get_visible_html({ removeScripts: false, maxLength: 50000 }); ``` -------------------------------- ### Create Custom Docker Network Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Create a custom Docker network and run the Playwright MCP server container on it for custom network configurations. ```bash docker network create mcp-network docker run -i --rm --network mcp-network mcp-playwright:latest ``` -------------------------------- ### Get Visible Page Text Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Extract visible text content from the current page, excluding hidden elements. ```javascript // Get all visible text await playwright_get_visible_text({}); // Get text with custom max length await playwright_get_visible_text({ maxLength: 5000 }); ``` -------------------------------- ### Health Monitoring with jq Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Format health status output using jq. ```bash curl http://localhost:8931/health | jq ``` -------------------------------- ### Responsive Web Design Testing Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Demonstrates navigating to a URL and resizing the viewport to specific device dimensions. ```javascript await playwright_navigate({ url: "your-site.com" }); await playwright_resize({ device: "iPhone 13" }); // AI tests menu functionality ``` ```javascript await playwright_resize({ device: "iPad Pro 11" }); ``` -------------------------------- ### Remote Server Deployment Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Deploy the server on a remote machine and configure the client connection. ```bash # On remote server ssh user@remote-server playwright-mcp-server --port 8931 # Configure client to connect remotely { "mcpServers": { "playwright": { "url": "http://remote-server:8931/mcp" } } } ``` -------------------------------- ### Run Server with Environment Variables Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Pass environment variables to the Docker container to configure the server, such as skipping browser downloads. ```bash docker run -i --rm \ -e PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \ mcp-playwright:latest ``` -------------------------------- ### Configure Claude Desktop Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/local-setup/Installation.mdx Update the Claude Desktop configuration file to point to the local MCP server directory. ```json { "mcpServers": { "playwright": { "command": "npx", "args": [ "--directory", "/your-playwright-mcp-server-clone-directory", "run", "@executeautomation/playwright-mcp-server" ] } } } ``` -------------------------------- ### Background Service Management Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Run the server as a persistent background process and monitor logs. ```bash # Using nohup nohup playwright-mcp-server --port 8931 > server.log 2>&1 & # Check status curl http://localhost:8931/health # View logs tail -f server.log ``` -------------------------------- ### Get Visible HTML Content Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/release.mdx Retrieves the complete HTML content of the current web page. By default, script tags are removed and the output is truncated. ```python playwright_get_visible_html ``` -------------------------------- ### Cross-Device Comparison Prompt Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Prompt for comparing layout across multiple devices. ```text Compare how the navigation menu looks on: - iPhone 13 - iPad Pro 11 - Desktop Chrome Take screenshots and tell me if there are any layout issues. ``` -------------------------------- ### Context-Aware Testing Prompt Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Prompt for switching devices during an active test session. ```text Can you switch to iPhone SE (smaller screen) and check if the button is still clickable? ``` -------------------------------- ### Quick Device Switch Prompts Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Short prompts for switching devices. ```text Switch to Pixel 7 ``` ```text Try this on Galaxy S24 instead ``` ```text Show me desktop view ``` -------------------------------- ### Playwright MCP Server API Testing Support Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/release.mdx The Playwright MCP Server now includes support for various API testing methods, including GET, POST, PUT, PATCH, and DELETE requests. ```plaintext GET request POST request PUT request PATCH request DELETE request ``` -------------------------------- ### Desktop Browser Testing Prompts Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Natural language prompts for testing desktop browser viewports. ```text Test in Desktop Chrome ``` ```text Switch to Desktop Firefox ``` ```text Show desktop Safari view ``` ```text Test at full desktop resolution ``` -------------------------------- ### Generate Playwright Test Spec from Recorded Actions Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Recording-Actions.mdx This TypeScript code demonstrates a generated Playwright test spec. It navigates to a website, fills in login credentials, clicks the login button, and verifies successful login by checking the URL. Ensure Playwright is installed and configured. ```typescript import { test, expect } from '@playwright/test'; test('LoginTest_2024-03-23', async ({ page }) => { // Navigate to the login page await page.goto('https://www.saucedemo.com'); // Fill in username await page.fill('#user-name', 'standard_user'); // Fill in password await page.fill('#password', 'secret_sauce'); // Click login button await page.click('#login-button'); // Verify successful login await expect(page).toHaveURL(/.*inventory.html/); }); ``` -------------------------------- ### Device Recommendation Prompt Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Prompt to request expert advice on which devices to include in a test suite. ```text Which device should I test for mobile users? ``` -------------------------------- ### Run Server with User Permissions for Mounted Volumes Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Run the Docker container with specific user and group IDs to resolve permission issues when using mounted volumes. ```bash docker run -i --rm \ -v $(pwd)/data:/app/data \ --user $(id -u):$(id -g) \ mcp-playwright:latest ``` -------------------------------- ### Run Evaluations Source: https://github.com/executeautomation/mcp-playwright/blob/main/README.md Execute evaluations by providing the necessary API key as an environment variable. ```bash OPENAI_API_KEY=your-key npx mcp-eval src/evals/evals.ts src/tools/codegen/index.ts ``` -------------------------------- ### Execute Test Suites Source: https://github.com/executeautomation/mcp-playwright/blob/main/README.md Commands for running tests with or without coverage reports. ```bash # Run tests using the custom script (with coverage) node run-tests.cjs # Run tests using npm scripts npm test # Run tests without coverage npm run test:coverage # Run tests with coverage npm run test:custom # Run tests with custom script (same as node run-tests.cjs) ``` -------------------------------- ### Run Server with Resource Limits Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Limit the CPU and memory resources allocated to the Docker container to manage resource consumption. ```bash docker run -i --rm \ --cpus="2.0" \ --memory="2g" \ mcp-playwright:latest ``` -------------------------------- ### Combine Token and Headers Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-api/Examples.md Demonstrates how to combine token and headers, noting that custom Authorization headers override the token parameter. ```typescript // Token takes precedence if no Authorization header in custom headers await playwright_get({ url: 'https://api.example.com/data', token: 'bearer-token', headers: { 'X-Custom-Header': 'value' } }); // Custom Authorization header overrides token parameter await playwright_get({ url: 'https://api.example.com/data', token: 'this-will-be-ignored', headers: { 'Authorization': 'Basic xyz123', // This takes precedence 'X-Custom-Header': 'value' } }); ``` -------------------------------- ### Manage Server Ports Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Commands to identify port conflicts and switch to an alternative port. ```bash lsof -i :8931 playwright-mcp-server --port 9000 ``` -------------------------------- ### Run Server with Volume Mounts Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Mount local directories into the Docker container to persist data or share files, such as for logs or screenshots. ```bash docker run -i --rm \ -v $(pwd)/data:/app/data \ mcp-playwright:latest ``` -------------------------------- ### Build MCP Playwright from Source in Docker Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md This Dockerfile demonstrates how to build the MCP Playwright project from source within a Docker container. It uses a multi-stage build to keep the final image lean, copying only necessary artifacts from the builder stage. ```dockerfile FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 RUN npm ci COPY src ./src COPY tsconfig.json ./ RUN npm run build FROM node:20-alpine WORKDIR /app COPY --from=builder /app/dist ./dist COPY --from=builder /app/package*.json ./ RUN npm ci --only=production CMD ["node", "dist/index.js"] ``` -------------------------------- ### Debug SSE Connections Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Verify that the Server-Sent Events stream is established and sessions are registered. ```bash curl -N http://localhost:8931/mcp ``` ```bash grep "Transport registered" server.log ``` -------------------------------- ### Concurrent Client Testing Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Verify that the server tracks multiple active sessions in HTTP mode. ```bash # Start server playwright-mcp-server --port 8931 # Client 1 connects # Client 2 connects # Client 3 connects # Check active sessions curl http://localhost:8931/health # Returns: {"status":"ok","activeSessions":3} ``` -------------------------------- ### Monitor Server Metrics Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Retrieve memory usage and active session counts via the metrics and health endpoints. ```bash curl http://localhost:8932/metrics | jq '.memory' curl http://localhost:8931/health | jq '.activeSessions' ``` -------------------------------- ### Tablet Device Testing Prompts Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Natural language prompts for testing tablet device viewports. ```text Test this on iPad Pro 11 ``` ```text Show me the tablet view using iPad Air ``` ```text Switch to iPad Pro 12.9 in landscape ``` ```text Test on Galaxy Tab S4 ``` ```text Show tablet view on Pixel Tablet ``` -------------------------------- ### Take Screenshot with Custom Directory Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Takes a full-page screenshot and saves it to a custom directory specified by `downloadsDir`. Useful for organizing screenshots. ```javascript // Screenshot with custom directory await playwright_screenshot({ name: "report", fullPage: true, downloadsDir: "/path/to/screenshots" }); ``` -------------------------------- ### Orientation Testing Prompt Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Prompt for testing portrait and landscape modes. ```text Test the page in both portrait and landscape on iPhone 14: 1. Portrait mode first 2. Then landscape mode Check if content reflows properly. ``` -------------------------------- ### Monitoring Metrics Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Access health and metrics data, typically hosted on the port following the main server port. ```bash curl http://localhost:8932/health curl http://localhost:8932/metrics ``` -------------------------------- ### Android Phone Testing Prompts Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Natural language prompts for testing Android device viewports. ```text Test on Pixel 7 ``` ```text Show me this on Galaxy S24 ``` ```text Switch to Pixel 5 view ``` ```text Test on Galaxy S9+ in landscape ``` -------------------------------- ### Run Server in Interactive Mode Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Run the Docker container interactively, which is recommended for MCP servers that communicate via stdin/stdout. The container is automatically removed upon exit. ```bash docker run -i --rm mcp-playwright:latest ``` -------------------------------- ### Navigate Forward in Browser Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/release.mdx Performs a forward navigation in the browser's history. This tool complements the backward navigation functionality. ```python playwright_go_forward ``` -------------------------------- ### Simulate Keyboard Input Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Examples.md Focuses on an input field and triggers a key press event. ```bdd Given I navigate to website "https://example.com/form" When I focus on the input field with id "search-box" And I press the "Enter" key Then the search results should appear ``` -------------------------------- ### Take Basic Screenshot Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Takes a screenshot of the current page and saves it with the specified name. By default, it saves to the Downloads folder. ```javascript // Basic screenshot await playwright_screenshot({ name: "homepage" }); ``` -------------------------------- ### Emulate Devices with Playwright MCP Source: https://github.com/executeautomation/mcp-playwright/blob/main/README.md Use the playwright_resize function to emulate various devices. Supports automatic user-agent, touch support, and device pixel ratio. You can also specify orientation. ```javascript await playwright_resize({ device: "iPhone 13" }); ``` ```javascript await playwright_resize({ device: "iPad Pro 11", orientation: "landscape" }); ``` ```javascript await playwright_resize({ device: "Desktop Chrome" }); ``` -------------------------------- ### Log Analysis Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Filter and monitor server logs in real-time. ```bash # View logs in real-time tail -f server.log # Filter by level grep '"level":"error"' server.log # Track specific session grep '"sessionId":"abc-123"' server.log ``` -------------------------------- ### Cross-Browser Testing Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Automates screenshot capture across different desktop browser environments. ```javascript await playwright_resize({ device: "Desktop Chrome" }); await playwright_screenshot({ name: "chrome-view" }); await playwright_resize({ device: "Desktop Firefox" }); await playwright_screenshot({ name: "firefox-view" }); await playwright_resize({ device: "Desktop Safari" }); await playwright_screenshot({ name: "safari-view" }); ``` -------------------------------- ### Mobile Device Testing Prompts Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Natural language prompts for testing specific mobile device viewports. ```text Test this page on iPhone 13 ``` ```text Switch to iPhone 14 view ``` ```text Show me how this looks on iPhone SE ``` ```text Test on iPhone 13 in landscape mode ``` ```text Rotate to landscape orientation on iPhone 15 ``` ```text Switch iPhone to portrait mode ``` -------------------------------- ### SSE Stream (Legacy) Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Establishes a Server-Sent Events (SSE) connection for streaming data. This is a legacy endpoint. ```APIDOC ## GET /sse (Legacy) ### Description Establishes an SSE connection. This endpoint is intended for legacy use cases and may be deprecated in favor of the unified endpoint. ### Method GET ### Endpoint /sse ### Notes Use the `-N` flag with curl to disable output buffering for real-time streaming. ``` -------------------------------- ### Claude Desktop MCP Server Configuration Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Configure Claude Desktop to use the Dockerized Playwright MCP server by specifying the Docker command and arguments in the configuration file. ```json { "mcpServers": { "playwright-docker": { "command": "docker", "args": ["run", "-i", "--rm", "mcp-playwright:latest"] } } } ``` -------------------------------- ### Manual Testing and Inspection Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Manually verify endpoints or use the official MCP inspector. ```bash # Terminal 1: Start server playwright-mcp-server --port 8931 # Terminal 2: Test endpoints curl http://localhost:8931/health curl -N http://localhost:8931/mcp | head -5 curl http://localhost:8932/metrics ``` ```bash # Start server playwright-mcp-server --port 8931 # Test with official MCP inspector npx @modelcontextprotocol/inspector http://localhost:8931/mcp ``` -------------------------------- ### Resolve npx Output Issues Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Commands to fix missing console output or verify server status when using npx. ```bash npx @executeautomation/playwright-mcp-server@latest --port 8931 ``` ```bash npm install -g @executeautomation/playwright-mcp-server playwright-mcp-server --port 8931 ``` ```bash curl http://localhost:8931/health ``` -------------------------------- ### Verify Transport Sequence Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Log sequence verification for troubleshooting 'No transport found' errors. ```bash # Check logs for "Transport registered" - should appear before POST messages # Look for this sequence: # 1. "Incoming request" GET /mcp # 2. "SSE connection request received" # 3. "Transport registered" with sessionId # 4. "POST message received" with same sessionId # If sequence is wrong, client needs to reconnect ``` -------------------------------- ### Define Cursor Rules for Automated Testing Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/testing-videos/AIAgents.mdx Configures AI agents to perform specific UI navigation, data creation, and database verification tasks when triggered by the /test command. ```js When I say /test, then perform following Navigate to http://localhost:8000/Product/List. Create product by clicking Create link . Then create a product with some realistic data for Name, Price and Select ProductType as CPU and click create input type with id as Create. Check the Database for the created record Use the Schema: http://localhost:8001/swagger/v1/swagger.json Here is the baseURL of API Base URL: http://localhost:8001/ Also check the API which performs the GET operation if the values are correctly retreived for the created product from the above schema ``` -------------------------------- ### Dynamic Metrics Collection Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Access metrics using the dynamically assigned monitoring port. ```bash # Server output shows: # Monitoring HTTP server listening on port 59055 # Health check: http://localhost:59055/health # Metrics: http://localhost:59055/metrics ``` ```bash # Use the port from server output curl http://localhost:59055/metrics | jq ``` -------------------------------- ### Navigation with WebKit Browser Source: https://context7.com/executeautomation/mcp-playwright/llms.txt Navigates to a URL using the WebKit browser engine, with the option to run in headed mode. Useful for testing cross-browser compatibility. ```javascript await playwright_navigate({ url: "https://example.com", browserType: "webkit", headless: false }); ``` -------------------------------- ### Bug Investigation Workflow Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Resize-Prompts-Guide.md Captures screenshots across multiple mobile devices to reproduce layout issues. ```javascript await playwright_navigate({ url: "your-site.com/checkout" }); await playwright_resize({ device: "iPhone 13" }); await playwright_screenshot({ name: "checkout-iphone13" }); await playwright_resize({ device: "iPhone SE" }); await playwright_screenshot({ name: "checkout-iphoneSE" }); ``` -------------------------------- ### Save Page as PDF Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/Examples.md Exports the current page to a PDF file, with options for custom formatting and margins. ```bdd Given I navigate to website "https://example.com/report" When I save the current page as a PDF in "/downloads" folder with name "report.pdf" Then I should see confirmation that the PDF was saved ``` ```bdd Given I navigate to website "https://example.com/invoice" When I save the page as PDF with the following settings: | Setting | Value | | ----------------- | --------- | | Output Path | /downloads | | Filename | invoice.pdf | | Format | Letter | | Print Background | true | | Top Margin | 2cm | | Right Margin | 1cm | | Bottom Margin | 2cm | | Left Margin | 1cm | Then I should see confirmation that the PDF was saved ``` -------------------------------- ### Press Keyboard Key Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/release.mdx Simulates pressing a keyboard key. This can be used with or without focusing on a specific element. ```python playwright_press_key ``` -------------------------------- ### Run as Non-Root User in Dockerfile Source: https://github.com/executeautomation/mcp-playwright/blob/main/DOCKER.md Add this to your Dockerfile to run the container as a non-root user, enhancing security. Ensure the 'node' user has the necessary permissions. ```dockerfile FROM mcp-playwright:latest USER node ``` -------------------------------- ### Deploy via SSH Tunneling Source: https://github.com/executeautomation/mcp-playwright/blob/main/docs/docs/playwright-web/HTTP-SSE-Transport.mdx Securely expose the server running on a remote machine to a local environment. ```bash playwright-mcp-server --port 8931 ssh -L 8931:localhost:8931 user@remote-server ``` ```bash ssh -L 8931:localhost:8931 user@remote-server ```