Implementation:Microsoft Playwright LaunchApp
Overview
LaunchApp provides a utility function for launching browser-based applications in app mode, primarily used for Playwright's built-in UI tools like the trace viewer and code generator.
Description
The launchApp function launches a persistent browser context configured for app-mode usage. For Chromium, it uses the --app flag and configures window size/position. It auto-detects the best Chromium channel when no explicit channel or executable path is provided. The function handles error cases gracefully, including situations where no browsers are installed, and provides setup for page-level interactions.
Usage
Used internally by Playwright CLI tools to open UI applications like the Trace Viewer.
Code Reference
Source Location
packages/playwright-core/src/server/launchApp.ts (125 lines)
Function Signature
export async function launchApp(browserType: BrowserType, options: {
sdkLanguage: string;
windowSize: types.Size;
windowPosition?: types.Point;
persistentContextOptions?: Parameters<BrowserType['launchPersistentContext']>[2];
}): Promise<{ context: BrowserContext; page: Page }>
Import
import { launchApp } from './server/launchApp';
I/O Contract
Inputs
browserType: BrowserType-- the browser type to launch (typically Chromium)options.sdkLanguage: string-- SDK language for channel detectionoptions.windowSize: Size-- desired window dimensionsoptions.windowPosition: Point-- optional window positionoptions.persistentContextOptions-- additional context launch options
Outputs
- Returns an object with
contextandpagefor the launched application - Throws descriptive errors if browser launch fails
Related Pages
- Microsoft_Playwright_Server_Playwright -- Playwright root providing browser types
- Microsoft_Playwright_ProgressController -- Progress tracking for launch