Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Nightwatchjs Nightwatch Desired Capabilities Type Definitions

From Leeroopedia
Knowledge Sources
Domains Configuration, Type_System, Browser_Options
Last Updated 2026-02-12 00:00 GMT

Overview

TypeScript type definitions for the `NightwatchDesiredCapabilities` interface representing W3C WebDriver capabilities used to configure browser sessions.

Description

The desired-capabilities.d.ts file defines the NightwatchDesiredCapabilities interface for specifying browser session parameters. It supports:

  • Standard W3C capabilities: `browserName`, `browserVersion`, `platformName`, `acceptInsecureCerts`.
  • Legacy capabilities: `takesScreenShot`, `handlesAlerts`, `cssSelectorsEnabled`, `javascriptEnabled`, `databaseEnabled`, `locationContextEnabled`, `applicationCacheEnabled`, `browserConnectionEnabled`, `webStorageEnabled`, `acceptSslCerts`, `rotatable`, `nativeEvents`.
  • Chrome-specific: `'goog:chromeOptions'` (using the `ChromeOptions` interface) and deprecated `chromeOptions`.
  • Logging: `'goog:loggingPrefs'` for browser, driver, and server log levels.
  • Vendor extensions: Supports arbitrary `${string}:${string}` keys for vendor-specific capabilities (e.g., BrowserStack, Sauce Labs).

⚠️ Deprecation Warning: The `chromeOptions` property is deprecated in favor of `'goog:chromeOptions'` (W3C vendor prefix). See Heuristic:Nightwatchjs_Nightwatch_Warning_Deprecated_API_Members for migration guidance.

Usage

Use this type when configuring `desiredCapabilities` in `nightwatch.conf.ts` or when programmatically creating sessions via `Nightwatch.createClient()`.

Code Reference

Source Location

Signature

export interface NightwatchDesiredCapabilities {
  [key: `${string}:${string}`]: unknown;
  browserName?: string | null;
  browserVersion?: string;
  platformName?: string;
  acceptInsecureCerts?: boolean;
  'goog:chromeOptions'?: ChromeOptions;
  'goog:loggingPrefs'?: {
    browser?: string;
    driver?: string;
    server?: string;
  };
  // ... legacy capabilities
}

Import

import { NightwatchDesiredCapabilities } from 'nightwatch';

I/O Contract

Inputs

Name Type Required Description
browserName string / null No Target browser: chrome, firefox, safari, edge, etc.
browserVersion string No Specific browser version
platformName string No Target platform: WINDOWS, MAC, LINUX, ANDROID, IOS
acceptInsecureCerts boolean No Accept self-signed TLS certificates
goog:chromeOptions ChromeOptions No Chrome-specific configuration

Outputs

Name Type Description
Typed capabilities object NightwatchDesiredCapabilities Used in `desiredCapabilities` config or `createClient()` options

Usage Examples

Chrome with Custom Capabilities

import { NightwatchDesiredCapabilities } from 'nightwatch';

const capabilities: NightwatchDesiredCapabilities = {
  browserName: 'chrome',
  browserVersion: 'latest',
  platformName: 'LINUX',
  acceptInsecureCerts: true,
  'goog:chromeOptions': {
    args: ['--headless', '--no-sandbox'],
  },
  'goog:loggingPrefs': {
    browser: 'INFO',
    driver: 'WARNING',
  },
};

BrowserStack Vendor Capabilities

const bsCapabilities: NightwatchDesiredCapabilities = {
  browserName: 'chrome',
  'bstack:options': {
    os: 'Windows',
    osVersion: '11',
    buildName: 'nightly',
    sessionName: 'Login test',
  },
};

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment