Playwright Extension
π₯Plug & Play
Watch the demo
This tutorial covers how to add the Playwright MCP Server as a goose extension, to enable cross-browser testing and web automation across Chromium and Webkit.
TLDR
- goose Desktop
- goose CLI
Command
npx -y @playwright/mcp@latest
Configurationβ
info
Note that you'll need Node.js installed on your system to run this command, as it uses npx.
- goose Desktop
- goose CLI
- Launch the installer
- Click
Yesto confirm the installation - Click the button in the top-left to open the sidebar
- Navigate to the chat
- Run the
configurecommand:
goose configure
- Choose to add a
Command-line Extension.
β goose-configure
β
β What would you like to configure?
β Add Extension
β
β What type of extension would you like to add?
β β Built-in Extension
β β Command-line Extension (Run a local command or script)
β β Remote Extension (SSE)
β β Remote Extension (Streaming HTTP)
β
- Give your extension a name.
β goose-configure
β
β What would you like to configure?
β Add Extension
β
β What type of extension would you like to add?
β Command-line Extension
β
β What would you like to call this extension?
β Playwright
β
- Enter the command to run when this extension is used.
β goose-configure
β
β What would you like to configure?
β Add Extension
β
β What type of extension would you like to add?
β Command-line Extension
β
β What would you like to call this extension?
β Playwright
β
β What command should be run?
β npx -y @playwright/mcp@latest
β
- Enter the number of seconds Goose should wait for actions to complete before timing out. Default is
300seconds.
β goose-configure
β
β What would you like to configure?
β Add Extension
β
β What type of extension would you like to add?
β Command-line Extension
β
β What would you like to call this extension?
β Playwright
β
β What command should be run?
β npx -y @playwright/mcp@latest
β
β Please set the timeout for this tool (in secs):
β 300
β
- Enter a description for this extension.
β goose-configure
β
β What would you like to configure?
β Add Extension
β
β What type of extension would you like to add?
β Command-line Extension
β
β What would you like to call this extension?
β Playwright
β
β What command should be run?
β npx -y @playwright/mcp@latest
β
β Please set the timeout for this tool (in secs):
β 300
β
β Enter a description for this extension:
β Modern web testing and automation
β
- Choose
Nowhen asked to add environment variables.
β goose-configure
β
β What would you like to configure?
β Add Extension
β
β What type of extension would you like to add?
β Command-line Extension
β
β What would you like to call this extension?
β Playwright
β
β What command should be run?
β npx -y @playwright/mcp@latest
β
β Please set the timeout for this tool (in secs):
β 300
β
β Enter a description for this extension:
β Modern web testing and automation
β
β Would you like to add environment variables?
β No
β
β Added Playwright extension
Example Usageβ
Let's use goose with the Playwright extension to create a cross-browser testing suite. In this example, we'll demonstrate how goose can help you:
- Test a web application across multiple browsers
- Generate maintainable test code
- Capture screenshots for visual comparison
LLM
Anthropic's Claude 4 Sonnet was used for this task.
goose Promptβ
Test the random redesign generator app (https://blackgirlbytes.github.io/random-redesign-picker/)
in Chromium and WebKit. For each browser:
1. Navigate to the page
2. Click the "Pick My Combo" button
3. Verify the text changes
4. Take a screenshot
Then generate a Playwright test that works across all browsers.
goose Outputβ
Let's start with Chromium:
βββ browser_navigate | playwright ββββββββββββββββββββββββββ
url: https://blackgirlbytes.github....
Now let's wait for and click the button:
βββ browser_click | playwright ββββββββββββββββββββββββββ
element: button with text "Pick My Combo"
ref: <button>
Let's capture the first combo and click again to verify it changes:
βββ browser_click | playwright ββββββββββββββββββββββββββ
element: button with text "Pick My Combo"
ref: <button>
Let's take a screenshot of the Chromium view:
βββ browser_take_screenshot | playwright ββββββββββββββββββββββββββ
filename: chromium-redesign.png
Now let's test in Safari. I'll open a new tab for Safari:
βββ browser_tab_new | playwright ββββββββββββββββββββββββββ
url: https://blackgirlbytes.github....
Let's click the button in Safari:
βββ browser_click | playwright ββββββββββββββββββββββββββ
element: button with text "Pick My Combo"
ref: <button>
Let's click again to verify the text changes:
βββ browser_click | playwright ββββββββββββββββββββββββββ
element: button with text "Pick My Combo"
ref: <button>
Let's take a screenshot of the Safari view:
βββ browser_take_screenshot | playwright ββββββββββββββββββββββββββ
filename: safari-redesign.png
Now I'll generate a Playwright test that runs in all three browser environments. The test will verify the core functionality we just tested manually:
βββ browser_generate_playwright_test | playwright ββββββββββββββββββββββββββ
name: Random Redesign Picker Test
description: Test the random redesign generator functionality across browsers
steps: [
"Navigate to the application",
"Verify initial page content",
"Click button to generate first combination",
"Click button again to generate second combination",
"Verify combinations are different"
]
Here's the generated Playwright test that will run across Chromium, Firefox, and Safari:
import { test, expect } from '@playwright/test';
test.describe('Random Redesign Picker', () => {
test('should generate different random combinations', async ({ page }) => {
// Navigate to the application
await page.goto('https://blackgirlbytes.github.io/random-redesign-picker/');
// Verify initial page content
await expect(page).toHaveTitle('Redesign for the Ridiculous');
await expect(page.getByRole('heading', { level: 1 })).toContainText('π² Redesign for the Ridiculous');
// Verify button is visible
const comboButton = page.getByRole('button', { name: 'π Pick My Combo' });
await expect(comboButton).toBeVisible();
// Click button and get first combination
await comboButton.click();
// Wait for and store first combo
const firstComboElement = page.locator('generic').filter({ hasText: /^(?!.*π²).*$/ }).last();
await expect(firstComboElement).toBeVisible();
const firstComboText = await firstComboElement.textContent();
// Generate second combination
await comboButton.click();
// Wait for and get second combo
const secondComboElement = page.locator('generic').filter({ hasText: /^(?!.*π²).*$/ }).last();
await expect(secondComboElement).toBeVisible();
const secondComboText = await secondComboElement.textContent();
// Verify combos are different
expect(secondComboText).not.toEqual(firstComboText);
});
});
To use this test, you would need to:
1. Save it as `tests/random-redesign.spec.ts`
2. Configure your `playwright.config.ts` to include all three browsers:
import { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
projects: [
{
name: 'chromium',
use: { browserName: 'chromium' },
},
{
name: 'firefox',
use: { browserName: 'firefox' },
},
{
name: 'webkit',
use: { browserName: 'webkit' },
},
],
};
export default config;
You can then run the tests using:
npx playwright test
This will execute the test in all three browser environments. The test verifies:
1. The page loads correctly
2. The title and heading are correct
3. The combo button is visible
4. Clicking the button generates a combination
5. Clicking again generates a different combination
The test uses robust selectors and proper waiting mechanisms to ensure reliability across different browsers and network conditions.