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

Run Selenium on a Heroku dyno by adding Heroku’s heroku-community/chrome-for-testing buildpack, installing the selenium-webdriver JavaScript package, and launching Chrome with --headless and --no-sandbox. The buildpack places matching Chrome and ChromeDriver binaries on PATH, while your Node.js code controls the browser, enables JavaScript by default, and closes the session in a finally block.

What the setup contains

A working deployment has four separate parts:

  • Heroku dyno or Heroku CI: the environment that runs your application or test command.
  • Chrome for Testing buildpack: installs Chrome and the matching ChromeDriver together.
  • Node.js and selenium-webdriver: the JavaScript binding that creates and controls the browser session.
  • Chrome options: flags suited to a containerized Heroku process.

JavaScript is enabled in Chrome by default. You do not add a “JavaScript enabled” switch; avoid disabling it with a preference or command-line flag. The binding does not install a browser by itself, so the buildpack remains necessary on Heroku even though current Selenium documentation describes Selenium Manager as able to handle driver installation in other environments.

1. Add the current Heroku buildpack

Use heroku-community/chrome-for-testing. It installs Chrome and ChromeDriver as an aligned pair and exposes both commands on PATH. Resolve the executables through PATH rather than hard-coding an absolute location; buildpack layouts can change.

For an application dyno

  1. Open the Heroku Dashboard, select your app, and go to Settings.
  2. In Buildpacks, click Add buildpack and add https://github.com/heroku-community/chrome-for-testing. Keep your language buildpack in the list as well; Heroku runs buildpacks in order.
  3. Alternatively, configure it with the Heroku CLI: heroku buildpacks:add https://github.com/heroku-community/chrome-for-testing --app YOUR_APP.
  4. Redeploy so the buildpack downloads the browser and driver. The default channel is Stable. Set the configuration variable GOOGLE_CHROME_CHANNEL to Beta, Dev, or Canary only when your test suite specifically needs that channel.

For Heroku CI

Add the same Chrome for Testing buildpack to the CI test environment alongside the language buildpack. Your CI command still needs the selenium-webdriver dependency and Chrome options in test code; installing the buildpack does not create tests or choose a test runner.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
  • Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized

2. Prepare the Node.js project

Selenium’s current JavaScript API documentation specifies Node.js 22 or newer. Set an appropriate engine in package.json, then install the binding:

npm install selenium-webdriver

Commit the resulting package-lock.json. A minimal package.json can define a worker or test command:

{
  "engines": { "node": ">=22" },
  "scripts": { "start": "node screenshot.js", "test": "node test.js" },
  "dependencies": { "selenium-webdriver": "latest" }
}

Use a pinned dependency range for production after confirming the version that your application supports. Heroku’s Node.js buildpack supplies Node; the Chrome buildpack supplies the browser and driver.

3. Launch headless Chrome from JavaScript

This complete example navigates to a URL, reads the page title, and always terminates Chrome. It relies on PATH resolution, so no buildpack-specific filesystem path is embedded.

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.
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

async function main() {
  const options = new chrome.Options();
  options.addArguments(
    '--headless',
    '--no-sandbox',
    '--window-size=1365,1024'
  );

  // JavaScript remains enabled because we do not set a disabling preference.
  const driver = await new Builder()
    .forBrowser('chrome')
    .setChromeOptions(options)
    .build();

  try {
    await driver.get(process.env.TARGET_URL || 'https://example.com');
    console.log('Title:', await driver.getTitle());
    console.log('URL:', await driver.getCurrentUrl());
  } finally {
    await driver.quit();
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

--headless runs without a display, and --no-sandbox is typically required by Chrome inside a Heroku dyno. The application should not assume that a visible desktop is available. Add --disable-gpu only if your workload shows rendering problems, and add --remote-debugging-port=9222 only when a diagnostic or integration workflow requires a DevTools endpoint. They are conditional troubleshooting flags, not defaults for every app.

Rank #2
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
  • Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized

Wait for JavaScript-rendered content

Calling get() waits for the navigation to reach its normal completion, but a single-page application may render important content afterward. Use an explicit wait for a stable condition instead of a long arbitrary sleep:

const { By, until } = require('selenium-webdriver');

await driver.get('https://your-app.example/dashboard');
await driver.wait(until.elementLocated(By.css('[data-testid="dashboard"]')), 15000);
const text = await driver.findElement(By.css('[data-testid="dashboard"]')).getText();

Choose a selector that represents the finished state. If content is loaded by an API, wait for the resulting element or an application-specific readiness marker.

4. Configure a Heroku process

For a web process, keep the HTTP server responsive and run browser work inside a request or a queued worker. For a one-off job, define a separate process type in Procfile:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
web: node server.js
browser: node screenshot.js

Run the browser job with heroku run browser --app YOUR_APP. Avoid starting one Chrome process per incoming request without limits; concurrent sessions consume dyno memory and CPU quickly. Reuse no driver across unrelated jobs unless you deliberately isolate cookies, local storage, and failure recovery.

5. Heroku CI test configuration

In Heroku CI, put the Chrome for Testing buildpack in the test environment’s buildpack list. Configure the test script in package.json, for example:

Rank #3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
  • CanaKit Raspberry Pi 5 Essentials Starter Kit
{ "scripts": { "test": "node --test test/**/*.test.js" } }

Your test files create and quit their own driver. A failed test must still execute cleanup; otherwise a hanging browser can make the CI command exceed its timeout. Keep test data and target URLs in environment variables rather than committing credentials.

6. Buildpack choices: current and legacy

Approach Chrome and driver relationship Flag behavior Recommendation
heroku-community/chrome-for-testing Installs a matched Chrome/ChromeDriver pair Set flags in Selenium options Current default for dynos and Heroku CI
Old separate Google Chrome and ChromeDriver buildpacks Versions can drift apart Older shims may inject flags Do not use for a new setup
Archived standalone ChromeDriver buildpack Not maintained as the preferred route Depends on legacy configuration Avoid

The old Google Chrome buildpack documentation described a shim that added flags automatically and advised Selenium users not to install it. Chrome for Testing behaves differently: configure the flags where Chrome is launched.

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

7. Troubleshooting

“Unable to obtain driver” or a missing Chrome binary

Confirm the Chrome for Testing buildpack is attached to the same app or CI environment as the language buildpack, then redeploy. In a dyno, inspect availability with which google-chrome and which chromedriver. Do not paste a path from an old buildpack release into code.

Chrome exits immediately or reports a sandbox error

Ensure --headless and --no-sandbox are present in the chrome.Options object before building the driver. If rendering still fails, try --disable-gpu and capture the complete driver log.

The page is blank or elements never appear

Check the target URL from the dyno, authentication requirements, outbound access, and application logs. Replace fixed sleeps with an explicit wait for a selector. A successful navigation does not guarantee that a client-rendered component has finished loading.

Rank #4
SANOOV Raspberry Pi 5 4GB Kit, 4GB RAM Single Board Computer with Active Cooler and ABS Case, Complete Raspberry Pi 5 Starter Kit for IoT Robotics Retro Gaming
  • All-in-One Complete Kit: This SANOOV RPi 5 bundle comes with Raspberry Pi 5 4GB RAM single board, active cooler, durable ABS case and screwdriver. No extra parts needed, ready to use right out of the box for beginners and hobbyists
  • Powerful Single Board Computer: Equipped with 4GB RAM and high-performance processor, delivers fast running speed for 4K playback, AI projects, programming and daily computing tasks. SANOOV for raspberry pi 5 4GB is equipped with broadcom 64 quad-core Arm Cortex A76 processor with gigabit ethernet and upgraded with IEEE 802.11ac Wi-Fi, Bluetooth 5.0 dual-band 2.4Ghz and 5Ghz and Power Over Ethernet (POE). Upgrading delivers 2-3 x speed vs Pi 4, redefining the experience
  • Efficient Active Cooler: Effectively lowers operating temperature and prevents performance throttling. Runs quietly even under long-time heavy load, ensures stable operation all day long. SANOOV RPi 5 4GB kit offer an active cooler, which combines an aluminium heatsink with a high-performance PWM fan. Active cooler is fully compatible with the Pi OS, which can effectively reduce the temperature of RPi5 and ensure its good performance during long-term high load operation
  • Sturdy ABS Protective Case: Well-fitted for Raspberry Pi 5 board, can be secured with 4 screws to effectively protect the Pi 5 motherboard from damage, reserves full access to all ports and buttons. SANOOV uses ABS material to produce the case, which has a softer texture and feel. Meanwhile, SANOOV case adopts a layered design for easy disassembly and installation. (Tip: The Case cannot install M.2 HAT Add on Board and Solid State Drive!)
  • Wide Application & Full Compatibility: Seamlessly compatible with official OS and mainstream peripheral accessories for Raspberry Pi 5. Whether you are a beginner, student, electronics hobbyist or professional developer, this all-in-one kit meets your diverse needs. It excels in IoT projects, robotics design, retro gaming devices, home media servers and other DIY creations. Backed by a large global community, you can easily find guides, technical support and shared projects online

Tests pass locally but fail in Heroku CI

Compare Node.js versions, browser channel selection, environment variables, viewport size, and test timing. Ensure the CI buildpacks include Chrome for Testing and that the test command actually runs the files containing Selenium code.

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

The process times out or memory is exhausted

Always call quit(), limit concurrent sessions, avoid unnecessarily large full-page captures, and split long suites into smaller CI jobs. Browser memory use depends on the pages and number of tabs; the setup itself does not establish a universal capacity.

Cookies or login state leak between tests

Create a fresh driver per isolated test group, or explicitly clear cookies and storage before the next case. Never share a driver containing credentials between unrelated users.

8. Reliability and maintenance checklist

  • Pin and review Node and npm dependency updates.
  • Use the Stable Chrome channel unless a different channel is a deliberate test target.
  • Keep browser and driver supplied by the same Chrome for Testing buildpack.
  • Use explicit waits and bounded timeouts for asynchronous UI states.
  • Log the failing URL, browser error, and test name, but never secrets or session cookies.
  • Recheck Heroku and Selenium documentation when buildpack releases, Chrome channels, or Node requirements change.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot rather than an in-dyno browser session, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.

See the parameter reference in the ScreenshotNeo documentation. A cURL call is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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}`);

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Every feature is included on every plan; 1,000 screenshots per month are free with no card, and paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Best Value
RasTech Raspberry Pi 5 8GB Kit with Active Cooler and Pi5 Case
  • 【What you Get】You will get 1*Pi 5 8GB Single Board,1*RasTech Case,1*Active Cooler,1*Screwdriver,1*Installation instructions,12-month free warranty, lifetime service, 24-hour prompt and friendly response.
  • 【More Connectors】There are two USB 3.0 ports(5Gbps simultaneously) and two USB 2.0 ports, which triple total bandwidth ,support any combination of up to two cameras or displays. Peak SD card performance is doubled through support for the SDR104 high-speed mode. It provides a smooth desktop experience for you. Offer Gigabit Ethernet and a PCIe interface, along with dual-band Wi-Fi and Bluetooth 5.0/BLE wireless capability. The RasTech Pi 5 Kit use the new 27W 5.1V 5A USB-C power connector.
  • 【 Support Dual 4Kp60 Display 】Each of the two microHDMI sockets can control a 4K display at 60 Hertz, now support HDR, offering super HD video for media streaming projects. RPi 5 is the first RPi model that comes with a PCI Express port (PCIe 2.0 x1 with 500 MB/s) to attach SSDs (requires separate M.2 HAT).
  • 【 Excellent Chips And Applications】Pi 5 is a full-size Pi computer using silicon built in-house at Pi. The RP1 “southbridge” provides the bulk of the I/O capabilities for Pi 5. Pi 5 is more friendly and convenient in the development of Internet of Things, Web development, machine identification, automatic control and other electronic equipment applications and network.
  • 【 Faster CPU, Better GPU 】 Pi 5 features a Broadcom BCM2712 64-bit quad-core Arm Cortex-A76 processor running at 2.4GHz, it delivers a 2–3× increase in CPU performance relative to RaspberryPi 4. The 800MHz VideoCore VII GPU is compatible to OpenGL ES 3.1 and Vulkan 1.2, substantial uplift in graphics performance. Pi 5 Offers lightning-fast CPU speed, a PCI Express interface, a Real Time Clock (RTC) and a power button and runs significantly cooler than Pi 4.

Frequently Asked Questions

Does Selenium disable JavaScript in headless mode?

No. Headless Chrome executes JavaScript unless your code or browser preferences explicitly disable it.

Can I use a non-Stable Chrome channel on Heroku?

Yes. Set the GOOGLE_CHROME_CHANNEL configuration variable to Beta, Dev, or Canary, then redeploy.

Is Heroku CI the same as a production dyno?

No. Both can use the Chrome for Testing buildpack, but CI runs your test command while a dyno runs the process types declared for the application.

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

The Bottom Line

For a new JavaScript Selenium deployment, use Heroku’s Chrome for Testing buildpack, resolve Chrome and ChromeDriver from PATH, pass the headless dyno flags in code, and close every driver session reliably.

Quick Recap

Bestseller No. 1
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$259.95
Bestseller No. 2
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$419.99
Bestseller No. 3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit
$189.99

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.