How can I help you?
From Complex Web Automation to Streamlined Workflows Code Studio Skills for Playwright MCP
15 Jun 202611 minutes to read
Overview
Ready to transform your web testing workflow? In this tutorial, you’ll learn how to use Playwright Model Context Protocol (MCP) with Code Studio’s Agent mode to generate, execute, and manage web automation tests with AI assistance. Playwright MCP acts as a bridge that enables Code Studio’s AI to perform real-world browser automation tasks based on your natural language instructions.
Key concept — Playwright MCP Server: A specific MCP implementation that brings Playwright’s browser automation capabilities to AI agents. It acts as a translator between natural language commands and browser actions. When you tell the AI to “verify the login button exists,” the Playwright MCP Server converts this into executable Playwright code that navigates pages, clicks elements, fills forms, and captures results.
Prerequisites
Before beginning this tutorial, ensure the following:
- Node.js (v18 or higher) is installed on your system. Playwright requires Node.js to run automation tests. Download from nodejs.org and verify installation with
node --version.
What You Will Learn
By the end of this tutorial, you’ll be able to:
- Install and configure Playwright MCP server in Code Studio
- Enable Agent mode for AI-powered test generation
- Create test scenarios in natural language and watch AI generate executable test scripts
- Review and execute generated Playwright tests
Steps to Generate Playwright Tests
Step 1: Install Playwright packages and Playwright MCP Server
Playwright is an open-source browser automation framework that lets you write tests for web applications across multiple browsers. The Playwright MCP Server acts as a bridge between Code Studio’s AI and Playwright’s automation capabilities — translating natural language test instructions into executable browser commands.
Before the AI can generate tests, you need to install both Playwright and the MCP server integration.
Steps:
- Create a new project folder and open it in Code Studio.
- Open the integrated terminal by clicking Terminal → New Terminal from the menu bar, or press
Ctrl+`(Windows/Linux) orCmd+`(Mac). -
Install Playwright by running the following command:
npm init playwright@latest - Follow the installation prompts:
- Press Enter to confirm installation
- Select TypeScript as the language (default) and press Enter

- Accept the default
testsfolder for end-to-end tests by pressing Enter

- When prompted “Add a GitHub Actions workflow?”, type
nand press Enter to skip it. This workflow would automatically run your tests on GitHub when you push code, but for this tutorial, you’ll focus on local development.

- Confirm installation of Playwright browsers by pressing Enter

The installation will download browser binaries. Once complete, you’ll see the Playwright folder structure in your project.

Note: The browser binaries download is approximately 500MB. The installation may take a few minutes depending on your internet connection speed.
-
Install the Playwright MCP Server:
-
Open the Chat Panel. If it’s not already visible, press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) to open the Command Palette, then type “Chat: Focus on Chat View” and press Enter. -
Once the Chat Panel is open, locate and click the Configure Chat icon (typically displayed as a settings or gear icon in the Chat Panel toolbar).
-
From the configuration menu that appears, select the MCP Server option. This will open the MCP marketplace view where you can browse and install available MCP servers.

- In the MCP marketplace panel, select the Playwright MCP tools

- Click the Install button and choose your installation option (global or local)

- Select your preferred option to add the Playwright MCP server to the installed list
-
- Verify the MCP installation:
- After installation completes, the Playwright MCP server connection status will show as active

- To verify the Playwright MCP server installation, click the Select Tools icon in Chat. You should see “MCP server: playwright” listed with available Playwright commands.

Step 2: Create the Required Skills
Skills are specialized instruction sets that direct the AI agent to perform specific tasks autonomously. Think of them as focused “playbooks” that define exactly how the agent should approach a particular type of work. In this case, you’ll create a skill that instructs the agent to explore a website using Playwright MCP, identify key user flows, and automatically generate test cases based on what it discovers.
Steps:
-
Open the Chat Panel. If it’s not already visible, press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) to open the Command Palette, then type “Chat: Focus on Chat View” and press Enter.-
Once the Chat Panel is open, locate and click the Configure Chat icon (typically displayed as a settings or gear icon in the Chat Panel toolbar).
-
From the configuration menu that appears, select the Agent Customizations option.

- From the Agent Customization menu that appears, select the Skills option.

-
-
In the Skills panel, locate and click the + New skill… button to create a new skill definition.

- Select path:
- A dialog will appear prompting you to select the path for your workspace. Select the path.

- Name your skill:
- A dialog will appear prompting you to enter a skill name. Type
playwright-explore-websiteas the skill name. Skill names must use lowercase letters, numbers, and hyphens only — no spaces or special characters are allowed. - Press Enter to confirm and create the skill.

- A dialog will appear prompting you to enter a skill name. Type
- Define the skill instructions:
- Code Studio will automatically open a new
SKILL.mdfile where you can define the instructions that guide the AI agent’s behavior. - Replace the default content with the following skill definition:
--- name: playwright-explore-website description: Website exploration for testing using Playwright MCP --- # Website Exploration for Testing Your goal is to explore the website and identify key functionalities. ## Specific Instructions 1. Navigate to the provided URL using the Playwright MCP Server. If no URL is provided, ask the user to provide one. 2. Identify and interact with 3-5 core features or user flows. 3. Document the user interactions, relevant UI elements (and their locators), and the expected outcomes. 4. Close the browser context upon completion. 5. Provide a concise summary of your findings. 6. Propose and generate test cases based on the exploration.
- Code Studio will automatically open a new
Step 3: Enter Your Test Scenario and Run the Agent
Now that the skill is configured, you can describe your test scenario in plain English and let the AI agent do the rest. The agent will autonomously explore the website, identify the elements you described, and generate executable test code — no manual scripting required.
Steps:
- Enable Agent Mode:
- Open Chat (if it’s not already visible, press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) to open the Command Palette, then type “Chat: Focus on Chat View” and press Enter) - Select Agent from the dropdown menu
- Open Chat (if it’s not already visible, press
- Select your skill:
- In the chat input box at the bottom of the Chat Panel, type a forward slash
/to open the skills menu. This displays the list of all available skills in your workspace. - From the skills menu, select
playwright-explore-website. This tells the agent to use the specific instructions you defined earlier for website exploration and test generation.
- In the chat input box at the bottom of the Chat Panel, type a forward slash
-
Enter your test scenario in natural language:
1. Navigate to "https://ej2.syncfusion.com/showcase/angular/appointmentplanner/#/dashboard". 2. Verify that the page title contains "Appointment Planner" or "Example Clinic". 3. Check that the header displays the logged-in user's name (e.g., "Jane Doe") and role (e.g., "Admin"). 4. Confirm the presence of the main navigation menu / sidebar with items like: Dashboard, Schedule, Doctors, Patients, Preference, About. 5. Verify that the "Logout" button/link is visible in the header or sidebar. 6. Check that clicking the "Dashboard" menu item (if visible) keeps/reloads the current view without errors.
-
Press Enter to submit your request.
- The Agent autonomously performs the following actions:
- Analyzes your test scenario and breaks it down into executable steps
- Uses Playwright MCP tools to interact with the browser and explore the website
- Generates the test code based on the exploration results
- Executes the generated test to verify it works correctly
- Prepares a summary of results and the generated test file

Step 4: Review the Generated Test
Once the agent finishes its work, you’ll have a complete, executable Playwright test. In this step, you’ll examine the generated code, verify it matches your requirements, and review the test execution results to confirm everything works as expected.
Steps:
-
Open the generated test file in the
tests/folder (e.g.,appointment-planner-verification.spec.ts) to review the generated test code:
-
To run the test, use the following command in the terminal:
npx playwright test appointment-planner-verifications.spec.ts
Note: Replace
appointment-planner-verifications.spec.tswith your actual test filename if different. -
Check the terminal output for test execution results.
The terminal shows live execution details as Playwright runs your test. By default, Playwright runs tests headless (without opening visible browser windows) and executes them in parallel across 3 workers (Chromium, Firefox, and WebKit).

-
View the HTML report by running the following command in the terminal:
npx playwright show-report

What’s Next
- Generate Your First Code Change Using Agent — Let AI write new code for you.
- Agent Mode — Explore advanced Agent mode capabilities and workflows.
- Improving Code Maintainability with Automated Clean Code Refactoring — Use AI to improve code quality automatically.