Implementation:Nightwatchjs Nightwatch Chrome Options Type Definitions
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Type_System, Browser_Options |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
TypeScript type definitions for Chrome-specific WebDriver capabilities, used within `desiredCapabilities['goog:chromeOptions']`.
Description
The chrome-options.d.ts file defines two interfaces:
- ChromeOptions — All Chrome-specific capabilities including `args` (command-line arguments), `binary` (Chrome executable path), `extensions`, `prefs` (user preferences), `detach`, `debuggerAddress`, `excludeSwitches`, `mobileEmulation`, `perfLoggingPrefs`, `windowTypes`, `androidPackage`, and `androidDeviceSerial`.
- ChromePerfLoggingPrefs — Performance logging configuration with `enableNetwork`, `enablePage`, `traceCategories`, and `bufferUsageReportingInterval`.
⚠️ Deprecation Warning: The `w3c` property is deprecated because ChromeDriver now only supports the W3C protocol. See Heuristic:Nightwatchjs_Nightwatch_Warning_Deprecated_API_Members for details.
Usage
Use these types when configuring Chrome-specific options in `nightwatch.conf.ts` within `desiredCapabilities['goog:chromeOptions']`. They provide autocompletion for all valid Chrome capability keys.
Code Reference
Source Location
- Repository: Nightwatchjs_Nightwatch
- File: types/chrome-options.d.ts
- Lines: 1-112
Signature
export interface ChromeOptions {
args?: string[] | undefined;
binary?: string | undefined;
extensions?: string[] | undefined;
localState?: Record<string, string> | undefined;
prefs?: Record<string, string> | undefined;
detach?: boolean | undefined;
debuggerAddress?: string | undefined;
excludeSwitches?: string[] | undefined;
mobileEmulation?: Record<string, string> | undefined;
perfLoggingPrefs?: ChromePerfLoggingPrefs | undefined;
windowTypes?: string[] | undefined;
androidPackage?: string;
androidDeviceSerial?: string;
}
export interface ChromePerfLoggingPrefs {
enableNetwork?: boolean | undefined;
enablePage?: boolean | undefined;
traceCategories?: string | undefined;
bufferUsageReportingInterval?: number | undefined;
}
Import
import { ChromeOptions, ChromePerfLoggingPrefs } from 'nightwatch';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| args | string[] | No | Chrome command-line arguments (e.g., `['--headless', '--disable-gpu']`) |
| binary | string | No | Path to Chrome executable |
| extensions | string[] | No | Base64-encoded .crx extension files |
| prefs | Record | No | Chrome user preferences |
Outputs
| Name | Type | Description |
|---|---|---|
| Typed Chrome config | ChromeOptions | Used within `goog:chromeOptions` in desiredCapabilities |
Usage Examples
Headless Chrome Configuration
import { NightwatchOptions } from 'nightwatch';
const config: NightwatchOptions = {
test_settings: {
default: {
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--headless', '--no-sandbox', '--disable-gpu'],
binary: '/usr/bin/google-chrome',
prefs: {
'download.default_directory': '/tmp/downloads',
},
},
},
},
},
};
Mobile Emulation
const mobileConfig = {
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
mobileEmulation: {
deviceName: 'Pixel 5',
},
},
},
};
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment