NPM wrapper for Selenium ChromeDriver that manages binary downloads and provides cross-platform browser automation support
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Core functionality for starting and stopping ChromeDriver processes programmatically, with port detection and readiness checking.
Starts a ChromeDriver process with optional command line arguments and readiness checking.
/**
* Start ChromeDriver process with optional arguments
* @param {string[]} args - Command line arguments for ChromeDriver (optional)
* @param {boolean} returnPromise - If true, returns Promise that resolves when ready (optional)
* @returns {ChildProcess|Promise<ChildProcess>} - Process or Promise resolving to process
*/
function start(args, returnPromise);Usage Examples:
const chromedriver = require('chromedriver');
// Basic start with default options
const process = chromedriver.start();
// Start with custom port
const processWithPort = chromedriver.start(['--port=9516']);
// Start with promise-based readiness checking
chromedriver.start(['--port=9515'], true)
.then((process) => {
console.log('ChromeDriver is ready and listening');
// Run your tests here
});
// Start with verbose logging
chromedriver.start(['--verbose', '--log-path=./chromedriver.log']);Behavior:
defaultInstancereturnPromise is true, waits for the specified port to become available--port=XXXX argumentStops the currently running ChromeDriver process.
/**
* Stop the running ChromeDriver process
* @returns {void}
*/
function stop();Usage Examples:
const chromedriver = require('chromedriver');
// Start ChromeDriver
chromedriver.start();
// Run your tests...
// Stop ChromeDriver
chromedriver.stop();
console.log('ChromeDriver stopped');Behavior:
defaultInstancedefaultInstance to nullAccess the currently running ChromeDriver process instance.
/**
* Currently running ChromeDriver process instance
* @type {ChildProcess|null}
*/
const defaultInstance;Usage Examples:
const chromedriver = require('chromedriver');
// Start ChromeDriver
chromedriver.start();
// Check if process is running
if (chromedriver.defaultInstance) {
console.log('ChromeDriver is running with PID:', chromedriver.defaultInstance.pid);
// Listen to process events
chromedriver.defaultInstance.on('exit', (code) => {
console.log('ChromeDriver exited with code:', code);
});
}
// Stop and verify
chromedriver.stop();
console.log('Is running:', chromedriver.defaultInstance !== null); // falseWhen the local ChromeDriver binary is not found, the system automatically falls back to the global binary:
// Automatic fallback behavior
if (!fs.existsSync(localBinaryPath)) {
console.log('Could not find chromedriver in default path:', localBinaryPath);
console.log('Falling back to use global chromedriver bin');
// Uses global 'chromedriver' or 'chromedriver.exe'
}The CLI wrapper handles SIGTERM signals for graceful shutdown:
// Automatic signal handling in CLI
process.on("SIGTERM", function() {
childProcess.kill("SIGTERM");
process.exit(1);
});Install with Tessl CLI
npx tessl i tessl/npm-chromedriver