Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/playwright/src/cli/client/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ async function program() {
case 'install':
await install(args);
return;
case 'install-browser':
await installBrowser();
return;
case 'show': {
const daemonScript = path.join(__dirname, 'devtoolsApp.js');
const child = spawn(process.execPath, [daemonScript], {
Expand Down Expand Up @@ -227,8 +230,7 @@ async function install(args: MinimistArgs) {
console.log(`✅ Skills installed to \`${path.relative(cwd, skillDestDir)}\`.`);
}

if (!args.config)
await ensureConfiguredBrowserInstalled();
await ensureConfiguredBrowserInstalled();
}

async function ensureConfiguredBrowserInstalled() {
Expand All @@ -251,6 +253,12 @@ async function ensureConfiguredBrowserInstalled() {
}
}

async function installBrowser() {
const { program } = require('playwright-core/lib/cli/program');
const argv = process.argv.map(arg => arg === 'install-browser' ? 'install' : arg);
program.parse(argv);
}

async function createDefaultConfig(channel: string) {
const config: Config = {
browser: {
Expand Down
10 changes: 9 additions & 1 deletion packages/playwright/src/cli/daemon/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,16 @@ const installBrowser = declareCommand({
name: 'install-browser',
description: 'Install browser',
category: 'install',
args: z.object({
browser: z.string().optional().describe('Browser to install'),
}),
options: z.object({
browser: z.string().optional().describe('Browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge'),
['with-deps']: z.boolean().optional().describe('Install system dependencies for browsers'),
['dry-run']: z.boolean().optional().describe('Do not execute installation, only print information'),
list: z.boolean().optional().describe('Prints list of browsers from all Playwright installations'),
force: z.boolean().optional().describe('Force reinstall of already installed browsers'),
['only-shell']: z.boolean().optional().describe('Only install headless shell when installing Chromium'),
['no-shell']: z.boolean().optional().describe('Do not install Chromium headless shell'),
}),
toolName: 'browser_install',
toolParams: () => ({}),
Expand Down
5 changes: 2 additions & 3 deletions tests/mcp/cli-misc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ test('daemon shuts down on browser launch failure', async ({ cli, server }) => {

test('install-browser', async ({ cli, server, mcpBrowser }) => {
test.skip(mcpBrowser !== 'chromium', 'Test only chromium');
await cli('open', server.HELLO_WORLD);
const { output } = await cli('install-browser');
expect(output).toContain(`Browser ${mcpBrowser} installed.`);
const { output } = await cli('install-browser', '--list');
expect(output).toMatch(/chromium-\d+/);
});

test('install workspace', async ({ cli }, testInfo) => {
Expand Down
Loading