Implementation:Microsoft Playwright ChromiumSwitches
| Knowledge Sources | |
|---|---|
| Domains | Chromium, Configuration |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Concrete tool for defining the default command-line switches used when launching Chromium browsers provided by the Playwright library.
Description
The `chromiumSwitches` module exports a function that returns an array of Chromium command-line flags optimized for automation. It disables numerous Chromium features that interfere with testing: field trial config, background networking, timer throttling, breakpad crash reporting, component updates, default browser checks, extensions, hang monitors, and various UI features. It also defines a `disabledFeatures` list that turns off features like `AvoidUnnecessaryBeforeUnloadCheckSync`, `HttpsUpgrades`, `MediaRouter`, `PaintHolding`, `ThirdPartyStoragePartitioning`, `Translate`, and `RenderDocument`. The function accepts optional parameters for assistant mode (which disables `AutomationControlled`), channel, and Android target.
Usage
Use ChromiumSwitches when constructing the launch arguments for Chromium-based browsers in Playwright, both for the CDP and BiDi connection paths.
Code Reference
Source Location
- Repository: Microsoft_Playwright
- File: packages/playwright-core/src/server/chromium/chromiumSwitches.ts
Signature
export const chromiumSwitches = (assistantMode?: boolean, channel?: string, android?: boolean): string[];
Import
import { chromiumSwitches } from '../server/chromium/chromiumSwitches';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| assistantMode | boolean | No | When true, disables the AutomationControlled feature flag |
| channel | string | No | Browser channel name (e.g., 'chrome', 'msedge') |
| android | boolean | No | Whether targeting an Android device |
Outputs
| Name | Type | Description |
|---|---|---|
| switches | string[] | Array of Chromium command-line switches for automation |
Usage Examples
import { chromiumSwitches } from '../server/chromium/chromiumSwitches';
const switches = chromiumSwitches(false, 'chrome', false);
// Returns: ['--disable-field-trial-config', '--disable-background-networking', ...]
const assistantSwitches = chromiumSwitches(true);
// Includes '--disable-features=...,AutomationControlled,...'