A Node.js CLI tool and library for installing and starting standalone Selenium servers with WebDriver support for multiple browsers.
npx @tessl/cli install tessl/npm-selenium-standalone@10.0.0Selenium Standalone is a Node.js CLI tool and library for installing and starting standalone Selenium servers with WebDriver support. It automatically downloads and manages Selenium server JARs and browser drivers (Chrome, Firefox, Internet Explorer, Edge, and Chromium Edge), providing both programmatic APIs and command-line interfaces for web automation testing workflows.
npm install selenium-standalone (local) or npm install selenium-standalone -g (global)const selenium = require('selenium-standalone');For ES modules:
import selenium from 'selenium-standalone';const selenium = require('selenium-standalone');
async function setupSelenium() {
// Install Selenium server and drivers
await selenium.install({
version: '4.10.0',
drivers: {
chrome: {
version: 'latest',
arch: process.arch
},
firefox: {
version: 'latest',
arch: process.arch
}
}
});
// Start Selenium server
const seleniumProcess = await selenium.start({
drivers: {
chrome: {
version: 'latest'
},
firefox: {
version: 'latest'
}
}
});
// Use seleniumProcess for WebDriver connections...
// Clean up when done
seleniumProcess.kill();
}Selenium Standalone consists of several key components:
Downloads and installs Selenium server and browser drivers with comprehensive configuration options including version control, proxy support, and progress reporting.
/**
* Downloads and installs Selenium server and browser drivers
* @param opts - Installation configuration options
* @returns Promise<InstallResult> Installation details with file paths and URLs
*/
function install(opts?: InstallOptions): Promise<InstallResult>;
interface InstallOptions {
/** Base directory for storing selenium files. Defaults to node_modules/selenium-standalone/.selenium */
basePath?: string;
/** Base URL for selenium server downloads. Defaults to GitHub releases */
baseURL?: string;
/** Map of drivers to download and install */
drivers?: Drivers;
/** Complete URL for selenium server jar as alternative to baseURL */
fullURL?: string;
/** Only downloads drivers explicitly specified when true */
ignoreExtraDrivers?: boolean;
/** Logging function for installation progress */
logger?: Logger;
/** Install only specific driver without selenium server */
onlyDriver?: keyof Drivers;
/** Progress callback for download progress reporting */
progressCb?: ProgressCallback;
/** HTTP request options for downloads (proxy, timeout, etc.) */
requestOpts?: RequestOptions;
/** Single driver installation mode */
singleDriverInstall?: keyof Drivers;
/** Selenium server version to install */
version?: string;
}
interface InstallResult {
/** File system paths for installed components */
fsPaths: Record<string, PathInfo>;
/** Download URLs used for installation */
urls: Record<string, string>;
/** Processed options used for installation */
opts: InstallOptions;
}
interface PathInfo {
/** Path where component is installed */
installPath: string;
/** Path where component was downloaded */
downloadPath: string;
/** Whether component requires executable permissions */
requireChmod?: boolean;
}Starts Selenium standalone servers or individual browser drivers with Java process management, port conflict resolution, and comprehensive configuration options.
/**
* Starts Selenium server or individual browser drivers
* @param opts - Start configuration options
* @returns Promise<ChildProcess> The running selenium or driver process
*/
function start(opts?: StartOptions): Promise<ChildProcess>;
interface StartOptions {
/** Base directory for selenium files */
basePath?: string;
/** Map of drivers to start along with selenium server */
drivers?: Drivers;
/** Array of arguments for the JVM */
javaArgs?: string | readonly string[];
/** Path to Java executable. Auto-detected if not provided */
javaPath?: string;
/** Start only specific driver without selenium server */
onlyDriver?: keyof Drivers;
/** Disable automatic port killing when false */
processKiller?: boolean;
/** Array of arguments for selenium server */
seleniumArgs?: string[];
/** Single driver start mode */
singleDriverStart?: keyof Drivers;
/** Spawn options for child process */
spawnOptions?: SpawnOptions;
/** Selenium server version to start */
version?: string;
}Provides selenium-standalone command with install and start subcommands, supporting configuration files and comprehensive options.
Installation Command:
selenium-standalone install [options]Start Command:
selenium-standalone start [options]Global Options:
--version <version> - Selenium server version--drivers.chrome.version <version> - Chrome driver version--drivers.firefox.version <version> - Firefox driver version--drivers.ie.version <version> - Internet Explorer driver version (Windows only)--drivers.edge.version <version> - Edge driver version (Windows only)--config <path> - Configuration file path--silent - Suppress progress output/** Configuration for browser drivers */
interface Drivers {
chrome?: DriverConfig;
firefox?: DriverConfig;
chromiumedge?: DriverConfig;
ie?: DriverConfig;
edge?: DriverConfig;
}
interface DriverConfig {
/** Driver version (supports 'latest') */
version: string;
/** Fallback version if latest detection fails */
fallbackVersion?: string;
/** Chrome channel for Chrome driver (stable, beta, dev) */
channel?: string;
/** Architecture (ia32, x64, arm64) */
arch: NodeJS.Architecture;
/** Arguments for driver when started alone */
onlyDriverArgs: string[];
/** Base URL for driver downloads */
baseURL: string;
}
/** Logging function type */
interface Logger {
(...args: any[]): void;
}
/** Progress callback for downloads */
interface ProgressCallback {
(total: number, progress: number | undefined, chunk: any, url: string, reset: any): void;
}
/** HTTP request configuration */
interface RequestOptions {
/** Request timeout in milliseconds */
timeout?: number;
/** HTTP proxy agent */
agent?: any;
/** Additional got options */
[key: string]: any;
}
/** Child process spawn options */
interface SpawnOptions {
/** Standard I/O configuration */
stdio?: string | Array<string>;
/** Working directory */
cwd?: string;
/** Environment variables */
env?: Record<string, string>;
/** Additional spawn options */
[key: string]: any;
}/** Default configuration values */
interface DefaultConfig {
/** Default Selenium server download URL */
baseURL: 'https://github.com/SeleniumHQ/selenium/releases/download';
/** Default Selenium version (4.10.0 or SELENIUM_VERSION env var) */
version: string;
/** Default driver configurations (IE and Edge drivers not included, require user configuration) */
drivers: {
chrome: {
version: 'latest';
channel: 'stable';
arch: NodeJS.Architecture; // process.arch
onlyDriverArgs: [];
baseURL: 'https://storage.googleapis.com/chrome-for-testing-public';
};
firefox: {
version: 'latest';
fallbackVersion: '0.30.0';
arch: NodeJS.Architecture; // process.arch
onlyDriverArgs: [];
baseURL: 'https://github.com/mozilla/geckodriver/releases/download';
};
chromiumedge: {
version: 'latest';
fallbackVersion: '117.0.2045.55';
arch: NodeJS.Architecture; // process.arch
onlyDriverArgs: [];
baseURL: 'https://msedgedriver.microsoft.com';
};
};
}Note: Internet Explorer and Edge (legacy) drivers are supported but not included in the default configuration. They are Windows-only and require explicit configuration including version and baseURL when used.
/** Supported environment variables */
interface EnvironmentVariables {
/** Override default Selenium version */
SELENIUM_VERSION?: string;
/** HTTP proxy for downloads */
HTTP_PROXY?: string;
/** HTTPS proxy for downloads */
HTTPS_PROXY?: string;
/** Environment mode (affects CLI testing behavior) */
NODE_ENV?: string;
}Custom Configuration:
const selenium = require('selenium-standalone');
// Install with custom configuration
await selenium.install({
version: '4.10.0',
baseURL: 'https://selenium-release.storage.googleapis.com',
drivers: {
chrome: {
version: '114.0.5735.90',
arch: 'x64',
baseURL: 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing'
}
},
requestOpts: {
timeout: 60000
}
});Driver-Only Mode:
// Install and start only Chrome driver
await selenium.install({
onlyDriver: 'chrome',
drivers: {
chrome: { version: 'latest' }
}
});
const chromeDriver = await selenium.start({
onlyDriver: 'chrome',
drivers: {
chrome: {
version: 'latest',
onlyDriverArgs: ['--port=9515', '--whitelisted-ips=']
}
}
});Configuration File:
// config.js
module.exports = {
version: '4.10.0',
drivers: {
chrome: { version: 'latest' },
firefox: { version: '0.30.0' }
}
};
// Usage with config file
// selenium-standalone install --config ./config.jsProxy Configuration:
await selenium.install({
requestOpts: {
agent: {
https: new HttpsProxyAgent('http://proxy-server:8080')
}
}
});