diff --git a/playwriter/src/cli.ts b/playwriter/src/cli.ts index c8373a8..e1b6938 100644 --- a/playwriter/src/cli.ts +++ b/playwriter/src/cli.ts @@ -179,7 +179,7 @@ async function executeCode(options: { cli .command('session new', 'Create a new session and print the session ID') .option('--host ', 'Remote relay server host') - .option('--browser ', 'Browser to use when multiple browsers are connected') + .option('--browser ', 'Browser ID to use when multiple browsers are connected') .action(async (options: { host?: string; browser?: string }) => { if (!options.host && !process.env.PLAYWRITER_HOST) { await ensureRelayServer({ logger: console, env: cliRelayEnv }) @@ -204,23 +204,11 @@ cli const shortId = extension.extensionId === 'default' ? 'default' : extension.extensionId.slice(0, 7) console.log(`${shortId.padEnd(7)} ${(extension.browser || 'Chrome').padEnd(7)} ${label}`) } - console.log('\nRun again with --browser .') + console.log('\nRun again with --browser .') process.exit(1) } else { - const byEmail = extensions.find((extension) => extension.profile?.email === options.browser) - const byId = extensions.find((extension) => extension.extensionId === options.browser) - const byBrowser = extensions.filter((extension) => (extension.browser || 'Chrome') === options.browser) - - selectedExtension = byEmail || byId || null - if (!selectedExtension && byBrowser.length === 1) { - selectedExtension = byBrowser[0] - } - + selectedExtension = extensions.find((extension) => extension.extensionId === options.browser) || null if (!selectedExtension) { - if (byBrowser.length > 1) { - console.error(`Browser name is ambiguous: ${options.browser}`) - process.exit(1) - } console.error(`Browser not found: ${options.browser}`) process.exit(1) } diff --git a/playwriter/src/executor.ts b/playwriter/src/executor.ts index 16d59de..29713d1 100644 --- a/playwriter/src/executor.ts +++ b/playwriter/src/executor.ts @@ -346,9 +346,11 @@ export class PlaywrightExecutor { return (await fallback.json()) as { connected: boolean; activeTargets: number } } const data = await response.json() as { - extensions: Array<{ extensionId: string; activeTargets: number }> + extensions: Array<{ extensionId: string; stableKey?: string; activeTargets: number }> } - const extension = data.extensions.find((item) => item.extensionId === extensionId) + const extension = data.extensions.find((item) => { + return item.extensionId === extensionId || item.stableKey === extensionId + }) if (!extension) { return { connected: false, activeTargets: 0 } }