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.

Principle:Nightwatchjs Nightwatch Client Initialization

From Leeroopedia
Knowledge Sources
Domains Testing, API, Session_Management
Last Updated 2026-02-12 00:00 GMT

Overview

A factory initialization pattern that creates a configured client, establishes a WebDriver session, and returns a ready-to-use browser API instance.

Description

Client Initialization is the two-step process of creating a client wrapper via createClient() and then launching the browser via launchBrowser(). The first step configures settings and creates the internal NightwatchClient. The second step initializes the Nightwatch API, creates a WebDriver session (starting the browser process), and returns the browser API object.

This separation allows configuration to be adjusted (via updateCapabilities()) between creation and launch, and supports both API-loaded and bare WebDriver modes.

Usage

Use this pattern in programmatic scripts when you need to control the full lifecycle of the browser session, from creation through execution to cleanup.

Theoretical Basis

The initialization follows a two-phase factory pattern:

  1. Phase 1 (Create): Configure settings, create internal client
  2. Phase 2 (Launch): Initialize APIs, create WebDriver session, return browser
  3. Optional: Update capabilities between phases

Related Pages

Implemented By

Page Connections

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