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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Set directConnect: true in Protractor, keep ChromeDriver available, and pass Chrome’s headless argument through capabilities.chromeOptions.args. Protractor then starts a local ChromeDriver connection instead of launching Selenium Server; Selenium Server is not required, but ChromeDriver still is.

Minimal working configuration

Create or update protractor.conf.js like this:

exports.config = {
  directConnect: true,

  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: [
        '--headless=new',
        '--window-size=1280,800'
      ]
    }
  },

  specs: ['e2e/**/*.spec.js']
};

directConnect: true tells Protractor to connect directly to the browser driver. In this mode, Protractor does not start Selenium Server and does not use a configured seleniumAddress. The setting supports Chrome and Firefox; this article uses Chrome.

The --headless=new argument enables Chrome’s current headless implementation. The fixed window size makes responsive breakpoints deterministic, which is useful when assertions depend on layout.

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

What still has to be installed

Chrome or Chromium

Install a browser binary that your test environment can launch. Headless mode suppresses the visible window; it does not remove the browser itself.

ChromeDriver

ChromeDriver remains the WebDriver implementation even when Selenium Server is removed. Put the executable on the system PATH, or point Protractor to it with the chromeDriver configuration property:

exports.config = {
  directConnect: true,
  chromeDriver: '/opt/webdrivers/chromedriver',
  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ['--headless=new', '--window-size=1280,800']
    }
  }
};

Use an absolute path when CI machines have different PATH values. The driver must be executable by the account running Protractor.

Protractor project dependencies

Install Protractor and your test dependencies in the project as usual. Direct connection changes how Protractor reaches the driver; it does not replace your test runner, framework, or browser automation API.

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

Converting a Selenium Server configuration

A server-based configuration often contains both a Selenium endpoint and browser capabilities:

exports.config = {
  seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
  capabilities: {
    browserName: 'chrome'
  }
};

For a local headless run, remove seleniumAddress, add directConnect: true, and add Chrome arguments:

exports.config = {
  directConnect: true,
  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ['--headless=new', '--window-size=1280,800']
    }
  }
};

Do not leave a conflicting remote endpoint in the configuration. The purpose of directConnect is to bypass Selenium Server startup and an existing seleniumAddress, while still using the local driver executable.

Choosing Chrome headless arguments

--headless=new versus --headless

Both spellings are used in Chrome documentation. --headless=new explicitly selects the newer implementation, while current Chrome documentation uses --headless for unified headless mode. Pick one convention for a given CI image and keep it pinned with the browser version you test.

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.

Chrome 112 changed unified headless behavior so Chrome creates platform windows without displaying them. From Chrome 132 onward, the old headless implementation is no longer bundled in the main Chrome binary; it is supplied as the separate chrome-headless-shell. Do not depend on undocumented legacy behavior when upgrading a build image.

Window dimensions

Add --window-size=WIDTH,HEIGHT whenever CSS breakpoints, screenshots, or element coordinates matter. Without an explicit size, the effective viewport can differ between developer machines and CI.

When not to add --disable-gpu

Many older snippets include --disable-gpu, especially for historical Windows workarounds. Treat it as compatibility baggage rather than a default requirement. Add it only when a specific browser or environment demonstrates a graphics-related failure.

Inspecting a failing headless page

To inspect a headless target, add --remote-debugging-port=0:

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.
chromeOptions: {
  args: [
    '--headless=new',
    '--window-size=1280,800',
    '--remote-debugging-port=0'
  ]
}

Chrome prints a DevTools WebSocket endpoint. Open that endpoint from another Chrome instance to inspect the page while the test is running. Remove the flag for ordinary CI runs unless you need this diagnostic access.

Running the test

  1. Verify that Chrome starts from the same account that will run Protractor: google-chrome --headless --version (or the equivalent executable for your platform).
  2. Verify that ChromeDriver is discoverable: chromedriver --version. If this command fails, use the chromeDriver absolute path in the configuration.
  3. Run Protractor with your normal project command, for example npx protractor protractor.conf.js.
  4. Watch the first startup lines. A successful direct run should launch ChromeDriver locally rather than contacting a Selenium Server URL.

ChromeDriver and Chrome must be compatible with each other. The supplied material does not establish a current version matrix, so keep both versions controlled by your CI image and consult the release documentation for the specific versions you install.

CI and container considerations

No Xvfb is normally needed

Headless Chrome is designed for unattended environments without a visible UI, so it normally removes the need for Xvfb or another display server. If your image adds a display server for unrelated GUI tests, it can remain, but direct headless Chrome does not require one.

Filesystem and sandbox permissions

Chrome must be able to create a temporary profile and cache. A read-only home directory, an unwritable temporary directory, or a container user with insufficient permissions can make Chrome exit before WebDriver creates a session. Give the runner a writable temporary location and run ChromeDriver under the same user as the test process.

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

Stable viewport and locale

Set a window size in the capabilities and control other environment-dependent inputs in the test. This prevents a desktop runner and a narrow CI container from selecting different responsive layouts.

Logs and artifacts

Capture Protractor, ChromeDriver, and browser console output on failure. For visual failures, save a screenshot and page source from the test before the browser session closes. If the failure is timing-related, first determine whether the page is still loading rather than adding arbitrary sleeps.

Common errors and fixes

Symptom Likely cause Fix
directConnect still tries to use a server seleniumAddress or another remote setting remains active Remove the server endpoint for the local profile and keep directConnect: true.
“Cannot find Chrome binary” Chrome is not installed or is outside the expected path Install Chrome/Chromium or configure the browser binary through the Chrome options supported by your environment.
“ChromeDriver executable needs to be available” Driver is not on PATH Install ChromeDriver, make it executable, or set chromeDriver to its absolute path.
Session starts, then immediately exits Browser and driver mismatch, or a permissions problem Check both version outputs, inspect ChromeDriver logs, and provide a writable temporary/profile directory.
Elements are missing in headless mode Different viewport or the page has not finished rendering Set --window-size, wait for a meaningful element, and capture page source to distinguish layout from timing.
Old tutorials require --disable-gpu Historical compatibility guidance Try the modern configuration first; add the flag only for a reproducible graphics failure in your target environment.
Need to see what the browser is doing Headless mode has no visible window Use --remote-debugging-port=0 temporarily and connect with DevTools, or rerun once without headless mode locally.

Direct connection versus a remote browser service

Direct connection is the simplest choice when the browser and ChromeDriver can run on the same machine as Protractor. You own the driver installation, browser version, filesystem, and CI isolation, and the test does not need a network hop to a hosted service.

A remote service can be preferable when your team does not want to maintain browser binaries, needs parallel machines, or must test from provider-hosted environments. The trade-offs are network dependence, provider-specific browser versions and capabilities, account requirements, and service cost. Protractor’s configuration model supports remote browser-testing integrations, but pricing and current compatibility vary by provider and should be checked directly before adoption.

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

Performance, reliability, and maintenance

Startup cost

Direct connection removes Selenium Server startup and one network layer, but every test session still pays Chrome and ChromeDriver startup costs. Reuse a browser session only when test isolation permits it; otherwise prioritize deterministic cleanup over marginal startup savings.

Reliability

Pin the browser and driver versions in CI, use an explicit viewport, and wait on application state rather than fixed delays. Record the exact Chrome, ChromeDriver, Node.js, and Protractor versions with failed runs so an image update can be correlated with a regression.

Security

Do not expose a remote debugging port to an untrusted network. If you enable it for diagnosis, bind and firewall the environment appropriately and remove the option afterward.

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 your goal is to obtain clean page images or PDFs rather than run Protractor assertions, ScreenshotNeo provides a single HTTP request. It accepts consent banners like a visitor and removes more than 60 known consent platforms, 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 the response identifies the result with X-Page-Verdict and X-Billed headers.

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

See the parameter reference in the ScreenshotNeo documentation. This cURL request saves a WebP image:

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(`HTTP ${res.status}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Its 63 options cover full-page and selector captures, dark mode, device presets, custom viewports, retina scale, PDF paper and page ranges, HTML/CSS rendering, JavaScript and clicks, selector waits, network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable caching, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification. Existing parameter names used by other screenshot APIs are accepted to ease switching.

The Free plan includes 1,000 shots each month with no card. Paid plans are Starter $5 for 3,000 shots, Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000; yearly billing gives two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to start without a card.

FAQ

Does directConnect work with Firefox?

Protractor documents direct connection for Chrome and Firefox. The headless arguments in this article are Chrome arguments; Firefox requires its own capability and option names.

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

Can I use directConnect with a hosted Selenium provider?

No. directConnect is for local driver connections. A hosted provider uses the remote configuration supplied by that provider and Protractor.

Is headless mode identical to headed Chrome?

It is intended to use the same browser engine, but viewport, font availability, GPU behavior, and environment permissions can still affect rendering. Validate visual or coordinate-sensitive tests in the same image used by CI.

Frequently Asked Questions

Does directConnect work with Firefox?

Protractor documents direct connection for Chrome and Firefox. The headless arguments in this article are Chrome arguments; Firefox requires its own capability and option names.

Can I use directConnect with a hosted Selenium provider?

No. directConnect is for local driver connections. A hosted provider uses its remote configuration instead.

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

Is headless mode identical to headed Chrome?

The browser engine is intended to be the same, but viewport, fonts, GPU behavior, and permissions can affect rendering. Validate sensitive tests in the same CI image.

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.