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

For a locally installed Chrome, run TestCafe with the chrome:headless alias and append Chrome switches to the same quoted browser parameter:

testcafe 'chrome:headless --no-sandbox' tests/sample-fixture.js

The quoted value is one TestCafe browser argument. On Windows cmd.exe, use double quotes instead. This syntax combines TestCafe’s documented headless alias and its documented argument format; verify any switch, such as --no-sandbox, against your own execution environment because it is an example, not a universal requirement.

What you need before launching

  • TestCafe installed in the project or available on your PATH.
  • Google Chrome installed locally, or a portable Chrome executable that TestCafe can discover.
  • A fixture or test file, such as tests/sample-fixture.js.
  • A shell whose quoting rules you understand. TestCafe can pass command-line arguments to installed and portable browsers on the current machine; a provider-backed browser is configured differently.

Headless mode removes Chrome’s visible window; it does not select a remote browser. The browser still runs wherever the selected TestCafe browser target is configured.

Run local Chrome from the command line

Unix-like shells

In Bash, Zsh and similar shells, quote the entire browser parameter so the alias and every switch reach TestCafe together:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Samsung 14" Galaxy Chromebook Go Laptop PC Computer, Intel Celeron N4500 Processor, 4GB RAM, 64GB Storage, ChromeOS, XE340XDA-KA2US, Student Laptop, Silver
  • SLIM. LIGHTWEIGHT. READY TO GO: The all-new slim design is perfect for busy lives on the go.
  • SKILLFULLY DESIGNED. MILITARY TOUGH: Built with premium craftsmanship to withstand the occasional drop or ding.
  • ALL-DAY, ALL-IN-ONE CHARGING: Power through your school day – and beyond – with a long-lasting 12-hour battery.¹
  • 3X FASTER THAN THE PREVIOUS GENERATION OF WIFI: Crush your schoolwork in record time with Wi-Fi that’s three times faster than the previous generation of Wi-Fi.
  • YOUR PHONE AND CHROMEBOOK WORK BETTER TOGETHER: Easily transfer files between devices, and control your phone right from your Chromebook.
testcafe 'chrome:headless --no-sandbox' tests/sample-fixture.js

chrome:headless selects TestCafe’s headless Chrome alias. The text after it is passed as Chrome command-line arguments. Replace --no-sandbox with the switch your environment actually needs; TestCafe does not require that flag in every setup.

Windows Command Prompt

cmd.exe uses double quotes for the same single browser parameter:

testcafe "chrome:headless --no-sandbox" tests/sample-fixture.js

Keep spaces and additional switches inside those quotes. If the shell splits the value, TestCafe may interpret the switch as a separate command-line argument rather than part of the browser definition.

Adding several switches

Append switches after the alias, separated by spaces, and keep the whole value quoted:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
testcafe 'chrome:headless --switch-one --switch-two=value' tests/sample-fixture.js

The example names are placeholders for real Chrome switches you have chosen. TestCafe’s documented mechanism is the placement and quoting; the effect and safety of each switch remain Chrome- and environment-specific.

Use the JavaScript Runner API

When TestCafe is started from JavaScript, select the same alias in the runner:

Rank #2
HP Chromebook 14 Laptop, Intel Celeron N4120, 4 GB RAM, 64 GB eMMC, 14" HD Display, Chrome OS, Thin Design, 4K Graphics, Long Battery Life, Ash Gray Keyboard (14a-na0226nr, 2022, Mineral Silver)
  • FOR HOME, WORK, & SCHOOL – With an Intel processor, 14-inch display, custom-tuned stereo speakers, and long battery life, this Chromebook laptop lets you knock out any assignment or binge-watch your favorite shows..Voltage:5.0 volts
  • HD DISPLAY, PORTABLE DESIGN – See every bit of detail on this micro-edge, anti-glare, 14-inch HD (1366 x 768) display (1); easily take this thin and lightweight laptop PC from room to room, on trips, or in a backpack.
  • ALL-DAY PERFORMANCE – Reliably tackle all your assignments at once with the quad-core, Intel Celeron N4120—the perfect processor for performance, power consumption, and value (2).
  • 4K READY – Smoothly stream 4K content and play your favorite next-gen games with Intel UHD Graphics 600 (3) (4).
  • MEMORY AND STORAGE – Enjoy a boost to your system’s performance with 4 GB of RAM while saving more of your favorite memories with 64 GB of reliable flash-based eMMC storage (5).
const createTestCafe = require('testcafe');

(async () => {
  const testcafe = await createTestCafe();
  try {
    const runner = testcafe.createRunner();
    await runner
      .src('tests/sample-fixture.js')
      .browsers('chrome:headless')
      .run();
  } finally {
    await testcafe.close();
  }
})();

This API form selects headless Chrome but does not add a CLI postfix. If your test run needs custom Chrome command-line settings, use the browser configuration object for a local executable:

const createTestCafe = require('testcafe');

(async () => {
  const testcafe = await createTestCafe();
  try {
    const runner = testcafe.createRunner();
    await runner
      .src('tests/sample-fixture.js')
      .browsers({
        path: '/path/to/chrome',
        cmd: '--no-sandbox --switch-one=value'
      })
      .run();
  } finally {
    await testcafe.close();
  }
})();

Use an executable path appropriate to the host operating system. The Runner API documents the { path, cmd } object and states that cmd is optional. Do not treat a path-based configuration as interchangeable with alias postfix syntax: the API documentation says the path: prefix does not support postfixes.

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

Choose the configuration that matches where Chrome runs

Browser location How TestCafe selects it Where arguments go Important boundary
Installed or portable Chrome on this machine chrome:headless alias, or a local { path, cmd } object Quoted CLI browser parameter, or the API object’s cmd field TestCafe must be able to discover or execute the local browser
BrowserStack Automate BrowserStack’s TestCafe provider alias BROWSERSTACK_CHROME_ARGS Set BROWSERSTACK_USE_AUTOMATE=1; this variable is specific to the documented BrowserStack provider
Another cloud provider That provider’s TestCafe plugin and alias The provider’s own launch configuration Do not assume local CLI switches are forwarded to a remote session
A custom headless browser provider A TestCafe provider plugin The plugin’s documented settings Provider plugins are separate from local Chrome alias handling

Configure BrowserStack separately

For the documented BrowserStack integration, Chrome arguments are supplied through the provider-specific environment variable, not by appending switches to a local chrome:headless value:

# Unix-like shell
export BROWSERSTACK_USE_AUTOMATE=1
export BROWSERSTACK_CHROME_ARGS="--switch-one --switch-two=value"

testcafe browserstack:chrome tests/sample-fixture.js

Use the equivalent environment-variable syntax for your CI system. The Automate flag must be enabled as required by the provider documentation. This setting should not be generalized to other cloud services; each provider plugin controls its own remote launch options.

Confirm what TestCafe reports at runtime

Inside a test, TestCafe exposes the active browser’s alias and headless state through t.browser.alias and t.browser.headless. Logging them can distinguish a headless local alias from an unexpected provider target:

import { Selector } from 'testcafe';

fixture`browser diagnostics`.page`https://example.com`;

test('print the active browser', async t => {
  console.log({
    alias: t.browser.alias,
    headless: t.browser.headless
  });

  await t.expect(Selector('body').exists).ok();
});

These properties report TestCafe’s browser mode and alias. They do not prove that a particular Chrome switch changed application behavior, so test that behavior separately.

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

Common mistakes and fixes

The shell says the command or browser is not found

TestCafe can launch only browsers installed or made available as portable executables on the current machine when you use local CLI arguments. Install Chrome, expose it to TestCafe, or use the API’s explicit path object with the correct executable path.

Chrome opens visibly instead of headlessly

Check that the value is exactly chrome:headless, with no typo, and that your shell kept the alias and switches inside one quoted parameter. In JavaScript, use .browsers('chrome:headless') rather than a path string with a postfix.

TestCafe treats a switch as another argument

Quote the complete CLI browser value. Unix-like shells use single quotes in the documented examples; Windows cmd.exe uses double quotes.

The API path configuration rejects a postfix

Do not write a path-based value as though it were an alias with a suffix. Supply the executable in path and command-line switches in cmd. The path-based form has a documented postfix limitation.

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.

A remote run ignores local Chrome switches

That is expected when the browser is supplied by a provider. Use the provider’s plugin settings. For BrowserStack, set BROWSERSTACK_USE_AUTOMATE=1 and provide arguments through BROWSERSTACK_CHROME_ARGS; do not assume this variable works with another service.

--no-sandbox causes concern or changes security posture

It is only an illustrative custom argument in the command above. Do not add it automatically. Determine why your execution environment requests it, apply the narrowest required setting, and follow your platform’s security policy.

Rank #4
HP 14" HD Chromebook Laptop for Students, Intel Quad-Core N4120(> N4020), 4GB RAM, 64GB eMMC, WiFi, Webcam, HDMI, USB-A&C, 14 Hours Battery Life, Zoom, Chrome OS, CUE Accessories
  • Intel Celeron N4120: 4 Cores & Threads, 1.1GHz Base Clock, Up to 2.6GHz Boost Clock, 4MB Cache, Intel UHD Graphics 600. The perfect combination of performance, power consumption, and value helps your device handle multitasking smoothly and reliably with four processing cores to divide up the work.
  • 14" HD Display: 14.0-inch diagonal, HD (1366 x 768), micro-edge, anti-glare. See your digital world in a whole new way. Enjoy movies and photos with the great image quality and high-definition detail of 1 million pixels.
  • Memory & Storage: 4 GB LPDDR4x & 64 GB eMMC Storage. Adequate high-bandwidth RAM to smoothly run multiple applications and browser tabs all at once. An embedded multimedia card provides reliable flash-based storage.
  • Ports:2 x USB 3.0 Type-A,1 x USB 3.0 Type-C,1 x HDMI,1 x Headphone Jack
  • Chrome OS: Chromebook is a computer for the way the modern world works, with thousands of apps. Enjoy the seamless simplicity that comes with Google Chrome and Android apps, all integrated into one laptop. It’s fast, simple, and secure.

The run is headless but the application still behaves differently

Headless status alone cannot establish that an application is equivalent to a headed session. Use the browser diagnostics to confirm the selected mode, then investigate the specific application behavior and Chrome switch involved.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Reliability and maintenance considerations

  • Keep selection and arguments separate. Use an alias when TestCafe’s built-in local browser discovery is sufficient; use { path, cmd } when you must identify a particular executable and its command line.
  • Make shell quoting explicit in CI. Store the complete browser parameter as one argument rather than concatenating unquoted strings.
  • Record the active target. Logging t.browser.alias and t.browser.headless helps detect a changed runner or provider configuration.
  • Treat provider settings as non-portable. BrowserStack’s environment variable belongs to its TestCafe provider. A migration to another provider requires that provider’s documented configuration.
  • Validate switches individually. A Chrome argument can affect startup, security, rendering or application behavior. Add one at a time so a failing launch has an identifiable cause.

Or skip the browser setup

If your goal is to obtain a clean image or PDF of a URL rather than execute a TestCafe interaction test, ScreenshotNeo provides a website screenshot API and MCP server. A single request can return PNG, JPEG, WebP or PDF. The API accepts the URL and access key directly:

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

See the full parameter reference in the ScreenshotNeo documentation.

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,
)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
const fs = require('node:fs');
fs.writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo removes cookie and consent banners, newsletter popups and chat widgets before capture; each cleanup step can be disabled. Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and response headers identify the page verdict and whether it was billed. It also offers an MCP server with take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients.

Every plan includes the feature set, including full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets, custom viewport and retina scale, PDF controls, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agent, authorization, timezone, geolocation, transparent backgrounds, resizing, selectable-TTL caching, signed image links, asynchronous webhooks, bulk capture for up to 100 URLs per call, a usage API and an OpenAPI specification. The parameter names used by other screenshot APIs are accepted to ease migration.

Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing provides two months free. You can start with 1,000 free screenshots a month with no card; paid plans start at $5 for 3,000 shots.

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.

Frequently Asked Questions

Is cmd mandatory in the TestCafe browser object?

No. TestCafe documents the cmd property as optional; provide it when the local executable needs additional command-line settings.

Can I use the BrowserStack Chrome-argument variable with another cloud provider?

No assumption is safe. BROWSERSTACK_CHROME_ARGS is a BrowserStack provider setting, so consult the other provider’s TestCafe plugin documentation for its equivalent, if one exists.

Does headless mode by itself verify that a Chrome switch worked?

No. t.browser.headless confirms the reported mode, but the application behavior affected by a switch requires its own assertion or diagnostic.

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.

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