Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Rails system tests with Selenium’s headless_chrome driver, and make sure Chrome plus a compatible driver are installed wherever the browser process runs. For Docker or CI, point Selenium at a separate browser service and configure Capybara so that service can reach your Rails test server. Keep the browser non-privileged and protect every automation port.

Choose where Chrome runs

There are two supported arrangements:

Arrangement Browser location What you configure Main trade-off
Local headless Chrome The Rails test machine, runner, or container Selenium, Chrome, and a compatible driver Simpler networking; browser and tests share one runtime
Remote browser A Selenium server or Chrome container Remote URL, browser options, and network-reachable Capybara host Separates workloads but adds service, DNS, port, and security work

Use local execution when your Rails process and browser can live in the same image or CI runner. Use a remote service when browser dependencies are maintained separately or several jobs share a browser environment.

Prerequisites and version boundaries

  • A Rails application with system tests enabled.
  • Selenium and Capybara as provided by, or configured for, your Rails test stack.
  • Google Chrome (or the Chromium build your environment supports) installed in the environment that launches the session.
  • A browser driver that Selenium can discover, with a version compatible with the installed browser.
  • For a remote setup, a Selenium/Chrome service reachable from the Rails process and able to reach the Rails test server.

Driver installation is platform- and runtime-specific. Do not copy a package command intended for one operating system into another image. Check the documentation for your Rails version, Selenium integration, browser build, and driver distribution, then verify the executables inside the actual CI or container runtime.

Local headless Chrome in a Rails system test

1. Configure the system-test base class

Rails places this configuration in application_system_test_case.rb:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
require "test_helper"

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :selenium, using: :headless_chrome
end

This tells Rails to create Selenium sessions with Chrome’s headless mode. The browser and driver must be available to the process running the test.

2. Add a real system test

require "application_system_test_case"

class HomePageTest < ApplicationSystemTestCase
  test "shows the welcome page" do
    visit "/"
    assert_text "Welcome"
  end
end

Run the system-test command used by your Rails version and test framework. If you use RSpec, Cucumber, a custom Capybara driver, or a production automation job, configure that integration point instead of copying the Rails test-case class unchanged.

3. Add driver options only when needed

Rails allows additional Capybara and driver settings in the system-test case. Keep options close to the integration that consumes them, and confirm their names against the versions installed in your application. Options accepted by one Selenium, Capybara, or Rails release are not automatically portable to another.

Running Chrome in a separate container or service

Remote Selenium configuration

Rails’ remote-browser pattern reads a URL from SELENIUM_REMOTE_URL. The following uses http://localhost:4444/wd/hub only as an example endpoint; the correct path depends on the Selenium version and service you deploy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
require "test_helper"

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  url = ENV.fetch("SELENIUM_REMOTE_URL", nil)

  options = if url
    { browser: :remote, url: url }
  else
    { browser: :chrome }
  end

  driven_by :selenium, using: :headless_chrome, options: options
end

When the variable is absent, the test uses a local Chrome session. When it is present, Selenium connects to the remote endpoint.

Make the Rails app reachable from the browser

A browser in another container cannot normally reach a Rails server bound only to loopback. Bind Capybara to an address available on the container network and set an app host that the browser service can resolve. The hostname and port must match your orchestration network:

if ENV["SELENIUM_REMOTE_URL"]
  Capybara.server_host = "0.0.0.0"
  Capybara.app_host = "http://rails-test:3000"
end

Here, rails-test is an example container or service name, not a universal value. Use the actual DNS name and exposed port from Docker Compose, Kubernetes, or your CI network. A loopback address inside the browser container refers to that container itself, not the Rails container.

Network checklist

  1. Confirm the Rails test server listens on the configured interface and port.
  2. Resolve the Rails service name from the browser container.
  3. Test TCP reachability from the browser container to the Rails port.
  4. Confirm the remote Selenium URL is reachable from the Rails process.
  5. Keep the Selenium control port on a private, trusted network.

Chrome and driver reliability

Driver discovery

A missing driver executable is a common first-run failure. Inspect the environment inside the process that launches Selenium, not only your interactive shell. Check the executable search path, file permissions, and the driver’s ability to start under the test user.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Browser-driver compatibility

Keep Chrome and its driver current and verify that their versions work together in the selected runtime. There is no single version pairing that applies to every operating system, Chrome channel, Selenium release, or container image.

Linux startup crashes

If Chrome exits immediately, collect Chrome and Selenium logs and check the runtime user. Launching Chrome as root can cause startup failures and is an unsafe deployment choice. Run the browser as a dedicated, non-privileged account instead.

Security for a server deployment

ChromeDriver exposes powerful browser automation controls. Chrome for Developers recommends using a test account without access to sensitive local or network data, never running ChromeDriver with a privileged account, and isolating it in a protected container or virtual machine.

  • Run Chrome and ChromeDriver as a non-root, least-privilege user.
  • Keep Chrome, ChromeDriver, Selenium Server, and base images updated.
  • Restrict the browser-control port with network policy or a firewall.
  • If remote access is required, allow only the intended client addresses.
  • Do not publish Selenium or ChromeDriver ports to the public internet to fix a test failure.
  • Give the browser test account only the files, credentials, and network routes it needs.

Troubleshooting common failures

“Unable to find driver” or a missing executable

Cause: Selenium cannot locate the driver in the runtime environment. Fix: install a compatible driver in the image or runner, put it on the process path (or configure its explicit location), and verify permissions as the test user.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Chrome starts locally but not in CI

Cause: the CI image lacks Chrome, has a different browser channel, or runs under a user with different permissions. Fix: inspect installed versions and browser logs inside CI, then align the image, driver, and user rather than relying on your workstation setup.

Chrome exits during startup on Linux

Cause: an unsuitable runtime user or container environment; root execution is a known risk. Fix: run as a non-privileged account, inspect stderr and Selenium logs, and confirm the browser has the libraries and writable directories it needs.

Remote session is created but the page will not load

Cause: the browser cannot resolve or connect to the Rails app host. Fix: set Capybara.server_host to a reachable interface, use the container DNS name in Capybara.app_host, expose the correct port, and test connectivity from the browser container.

Options are rejected after an upgrade

Cause: Rails, Capybara, Selenium, or the browser driver changed the accepted configuration shape. Fix: read the guide and API documentation for the installed Rails version and confirm the driver integration’s current option names.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance and operational trade-offs

Local execution removes a network hop and keeps failure diagnosis in one process, but every runner must carry a browser installation. A remote service centralizes browser maintenance and can isolate heavy browser processes, while introducing endpoint availability, DNS, port, and app-host dependencies. The supplied guidance does not establish a universal speed advantage for either mode, so measure your own suite if runtime is a deciding factor.

For repeatable CI runs, pin the browser image and driver policy, record versions in job logs, retain Selenium and Chrome logs on failure, and make the remote URL and app host explicit environment variables. Treat browser availability as infrastructure: health-check the service before tests and fail with a clear connectivity message.

Or skip the browser setup

If your goal is generating website screenshots rather than exercising a Rails system-test flow, ScreenshotNeo provides a one-call screenshot API and an MCP server for AI agents. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with verdict and billing information returned in headers. Every plan includes its features, including full-page capture, CSS-selector element capture, device and viewport controls, JavaScript and CSS, waits, blocking rules, authentication headers and cookies, PDFs, async jobs, bulk capture, caching, signed links, and usage reporting.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo documentation for request options. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients. Create a free ScreenshotNeo account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can I use headless Chrome in production code?

Yes, but the Rails system-test example is specifically for tests. Production automation should configure its own job lifecycle, credentials, timeouts, logging, and isolation.

Does headless mode remove the need for Chrome?

No. Headless means no visible window; the Chrome browser binary and a compatible Selenium driver are still required.

Is the sample remote URL always /wd/hub?

No. Treat that path as an example and use the endpoint documented by your Selenium service and version.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.