ChromeDriver is an NPM wrapper for Selenium ChromeDriver that automatically downloads and manages the appropriate ChromeDriver binary for web automation testing. It provides a Node.js interface to interact with ChromeDriver, handles cross-platform installation (macOS, Linux, Windows), and offers extensive configuration options including version management, proxy support, custom download URLs, and automatic Chrome version detection.
npm install chromedriverconst chromedriver = require('chromedriver');ES modules (via dynamic import):
const chromedriver = await import('chromedriver');const chromedriver = require('chromedriver');
// Get path to binary
console.log('ChromeDriver path:', chromedriver.path);
console.log('ChromeDriver version:', chromedriver.version);
// Start ChromeDriver programmatically
chromedriver.start(['--port=9515']);
// Run your Selenium tests here...
// Stop ChromeDriver
chromedriver.stop();ChromeDriver is built around several key components:
Core functionality for starting and stopping ChromeDriver processes programmatically, with port detection and readiness checking.
/**
* Start ChromeDriver process with optional arguments
* @param {string[]} args - Command line arguments for ChromeDriver
* @param {boolean} returnPromise - If true, returns Promise that resolves when ready
* @returns {ChildProcess|Promise<ChildProcess>} - Process or Promise resolving to process
*/
function start(args, returnPromise);
/**
* Stop the running ChromeDriver process
* @returns {void}
*/
function stop();Access to ChromeDriver binary path, version, and running instance information.
/**
* Path to the ChromeDriver binary executable
* @type {string}
*/
const path;
/**
* Version of the ChromeDriver binary
* @type {string}
*/
const version;
/**
* Currently running ChromeDriver process instance
* @type {ChildProcess|null}
*/
const defaultInstance;Comprehensive configuration system for customizing ChromeDriver installation behavior, including version selection, download sources, and platform-specific options. Configuration is handled through environment variables and npm configuration.
# Environment variable configuration options
CHROMEDRIVER_VERSION=LATEST # Specific version or 'LATEST'
CHROMEDRIVER_SKIP_DOWNLOAD=true # Skip binary download
CHROMEDRIVER_FORCE_DOWNLOAD=true # Force re-download
CHROMEDRIVER_CDNURL=https://example.com # Custom metadata endpoint
CHROMEDRIVER_CDNBINARIESURL=https://... # Custom binaries endpoint
CHROMEDRIVER_FILEPATH=/path/to/binary # Use local file path
DETECT_CHROMEDRIVER_VERSION=true # Auto-detect from Chrome
INCLUDE_CHROMIUM=true # Include Chromium in detectionDirect execution of ChromeDriver binary through the provided CLI wrapper.
# Direct execution with arguments
chromedriver [arguments]
# Example with port specification
chromedriver --port=9515 --verbose/**
* Node.js child process instance
* @typedef {Object} ChildProcess
* @property {function} kill - Terminate the process
* @property {Stream} stdout - Standard output stream
* @property {Stream} stderr - Standard error stream
* @property {function} on - Event listener registration
*/
/**
* Platform identifier for ChromeDriver binaries
* @typedef {'win32'|'win64'|'mac64'|'mac_arm64'|'mac-x64'|'mac-arm64'|'linux64'} PlatformId
*/