Firefox Runner CLI

1.4.0 · active · verified Sun Apr 19

fx-runner is a Node.js command-line interface (CLI) tool developed by Mozilla, designed to control and interact with Firefox browsers programmatically from the terminal. It simplifies tasks such as launching Firefox with specific profiles, passing arguments directly to the browser binary, and managing browser instances for testing or automation purposes. The project is actively maintained, with the latest stable version being 1.4.0, released in January 2024. Releases appear to be ad-hoc, driven by bug fixes and minor feature additions rather than a fixed cadence. Unlike full-fledged browser automation libraries (like Puppeteer or Playwright), `fx-runner` focuses purely on direct CLI interaction, making it particularly suitable for scripting environments, shell-based workflows, and scenarios where a lightweight, non-programmatic JavaScript control is preferred. Its primary differentiator is this direct command-line control over the Firefox binary and its associated profiles.

Common errors

Warnings

Install

Quickstart

Demonstrates how to execute the `fx-runner` CLI using Node.js's `child_process.spawn` to launch Firefox with a custom profile and a specific URL.

#!/usr/bin/env node

const { spawn } = require('child_process');

// Example: Start Firefox with a specific profile and additional arguments
const firefoxBinary = process.env.FIREFOX_BINARY || '/Applications/Firefox.app/Contents/MacOS/firefox'; // Adjust path for your OS
const profilePath = process.env.FIREFOX_PROFILE_PATH || './my-test-profile'; // Path to an existing or new profile
const urlToOpen = 'https://www.mozilla.org';

const args = [
  'start',
  '--binary', firefoxBinary,
  '--profile', profilePath,
  '--binary-args', `-url ${urlToOpen} -new-window`
];

console.log(`Launching Firefox with: fx-runner ${args.join(' ')}`);

const child = spawn('fx-runner', args, {
  stdio: 'inherit', // Pipe child process stdout/stderr to parent
  shell: true // Use shell to correctly interpret command and args
});

child.on('error', (err) => {
  console.error('Failed to start fx-runner:', err);
});

child.on('exit', (code, signal) => {
  if (code !== 0) {
    console.error(`fx-runner exited with code ${code} and signal ${signal}`);
  } else {
    console.log('fx-runner exited successfully.');
  }
});

view raw JSON →