or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

binary-info.mdcli.mdindex.mdinstallation-config.mdprocess-management.md
tile.json

process-management.mddocs/

Process Management

Core functionality for starting and stopping ChromeDriver processes programmatically, with port detection and readiness checking.

Capabilities

Start ChromeDriver

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:

  • Creates a child process spawning the ChromeDriver binary
  • Pipes stdout and stderr to the parent process
  • Stores the process instance in defaultInstance
  • If returnPromise is true, waits for the specified port to become available
  • Uses port 9515 by default, or extracts port from --port=XXXX argument
  • Falls back to global ChromeDriver binary if local binary is not found

Stop ChromeDriver

Stops 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:

  • Kills the process stored in defaultInstance
  • Sets defaultInstance to null
  • Safe to call even if no process is running

Process Instance Access

Access 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); // false

Error Handling

Binary Not Found

When 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'
}

Process Termination

The CLI wrapper handles SIGTERM signals for graceful shutdown:

// Automatic signal handling in CLI
process.on("SIGTERM", function() {
  childProcess.kill("SIGTERM");
  process.exit(1);
});