Webdriver Server

1.3.1 · maintenance · verified Sun Apr 19

webdriver-server is a foundational package within the Macaca.js ecosystem, designed to provide a standalone server that implements the WebDriver protocol. As of its current stable version, 1.3.1, it enables UI automation by allowing WebDriver clients (like testing frameworks) to connect and execute commands against various browsers and mobile applications, provided the necessary drivers are configured. The project appears to be in a maintenance phase, with the last notable activity indicated by its README update in late 2022 and npm last publish 2 years ago. It serves a specific role within the broader Macaca.js framework, offering a tailored environment for Macaca-based test automation. While not a direct competitor to general-purpose, feature-rich solutions like Selenium Grid or Appium in isolation, its strength lies in its tight integration and consistent operational model within the Macaca suite, making it a suitable choice for users already invested in that platform. Its release cadence is not rapid, reflecting a stable and mature, albeit slowly evolving, component.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate and start the `webdriver-server` using its `Server` class, listening on a specified port. It includes basic error handling and graceful shutdown logic.

import { Server } from 'webdriver-server';
import path from 'path';

// Ensure necessary browser drivers (e.g., chromedriver, geckodriver)
// are available in your system's PATH or explicitly configured.
// For example, you might install them globally or manage them with a tool like `webdriver-manager`.

async function startWebdriverServer() {
  const options = {
    port: 4444,
    host: 'localhost',
    logLevel: 'info', // Can be 'info', 'warn', 'error', 'debug'
    // Additional options for driver paths, capabilities, etc., would be configured here
    // based on the specific WebDriver client (e.g., Macaca, Selenium, Appium).
    // Example (if server directly manages drivers, which is not typical for a generic server):
    // chromeDriverPath: '/usr/local/bin/chromedriver',
  };

  try {
    const server = new Server(options); // Instantiate the WebDriver server
    await server.start(); // Start the server, making it listen for connections
    console.log(`WebDriver Server started successfully on http://${options.host}:${options.port}`);
    console.log('Press Ctrl+C to stop the server.');

    // Keep the process alive indefinitely, typically for a CI/CD environment or background service
    process.on('SIGINT', async () => {
      console.log('\nShutting down WebDriver Server...');
      await server.stop(); // Assuming a .stop() method exists for graceful shutdown
      process.exit(0);
    });
    process.on('SIGTERM', async () => {
      console.log('\nShutting down WebDriver Server...');
      await server.stop();
      process.exit(0);
    });

  } catch (error: any) {
    console.error('Failed to start WebDriver Server:', error.message);
    process.exit(1);
  }
}

startWebdriverServer();

view raw JSON →