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

To run Selenium tests against an Angular app in headless Chrome, start the app at a known URL, create a Selenium WebDriver session with Chrome’s --headless option, wait for Angular-rendered elements before using them, and close the driver after each test. In CI, use a headless Chrome or Chromium configuration supported by your Angular test setup; a display is not required.

How the Angular and Selenium pieces fit together

Angular CLI’s ng e2e command builds and serves the project, then invokes the end-to-end test builder configured for that project. If the project has no e2e target, the CLI can offer integrations such as WebdriverIO; the exact test runner depends on the project’s configuration. See Angular CLI e2e.

Selenium WebDriver is a language-neutral API and protocol for controlling browsers. Selenium communicates with a browser through its corresponding driver, so a Chrome session needs a compatible Chrome driver. Selenium’s setup guidance is at Getting started with Selenium WebDriver.

Headless mode changes how Chrome renders and runs: it operates without opening a visible browser window. In Selenium, pass --headless in Chrome options before building the driver. This does not remove the need for Chrome, a compatible driver, an accessible Angular server, or stable test synchronization. Chrome’s Selenium guidance is at Chrome Headless mode.

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.

Prepare the Angular app and test environment

Check for an e2e target

From the project root, inspect the Angular project configuration for an e2e target. If one is configured, use its builder and project-specific command. The CLI’s ng e2e flow handles building and serving the app before running that configured target. If there is no target, choose and configure an integration supported by the CLI rather than assuming that installing Selenium automatically creates an Angular e2e setup.

Install and align the browser components

Install the Selenium language binding used by your test code, Chrome or Chromium in the execution environment, and a Chrome driver compatible with that browser. Selenium’s browser-specific driver model means a browser/driver mismatch can prevent a session from starting. Keep browser and driver versions aligned in local development and CI, and follow the installation approach supported by your Selenium binding and environment.

Choose how the app will be served

You can let the Angular e2e target build and serve the project, or start the application separately and point Selenium at the resulting base URL. For a typical local Angular development server, that URL may be http://localhost:4200, but use the actual host and port configured for your run. In CI, ensure the test process can reach the server and that the server is ready before the first navigation.

Build a headless Chrome WebDriver

The following JavaScript example uses the official Selenium WebDriver API shape and Chrome’s headless option. Install selenium-webdriver and make Chrome plus a compatible Chrome driver available to the process before running it.

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

async function run() {
  const options = new chrome.Options().addArguments('--headless');
  const driver = await new Builder()
    .forBrowser('chrome')
    .setChromeOptions(options)
    .build();

  try {
    await driver.manage().setTimeouts({
      implicit: 0,
      pageLoad: 30000,
      script: 30000
    });

    await driver.get('http://localhost:4200');
    const heading = await driver.wait(
      until.elementLocated(By.css('[data-testid="page-heading"]')),
      10000,
      'Angular page heading did not appear'
    );
    await driver.wait(until.elementIsVisible(heading), 5000);

    const actual = await heading.getText();
    if (actual !== 'Dashboard') {
      throw new Error(`Expected Dashboard heading, received: ${actual}`);
    }
  } finally {
    await driver.quit();
  }
}

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

Replace the sample URL, selector, and expected heading with values from your application. The example deliberately uses an explicit wait instead of immediately querying an element: Angular may render or update the view after the initial document navigation completes. Selenium’s JavaScript example covers navigation, timeouts, element lookup, interaction, assertions, and teardown at Selenium WebDriver getting started.

Use selectors that survive UI changes

Prefer stable attributes intended for tests, such as a team’s data-testid convention, or accessible roles and labels where your test tooling supports them. Avoid selectors tied to generated class names or incidental DOM nesting. For a user flow, wait for the specific control or result needed by the next step, interact with it, and assert the visible outcome rather than relying on a fixed sleep.

Always tear down the session

Place driver.quit() in a finally block or your test framework’s teardown hook. This releases the browser session even when an assertion fails. Without teardown, orphaned Chrome processes can consume CI resources and make later runs less predictable.

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).

Run the tests locally and in CI

Run through Angular CLI

When an e2e target is configured, run ng e2e from the Angular workspace (or pass the project name when the workspace has multiple projects). The configured builder is responsible for the test integration. Confirm the builder’s own command-line options if you need to pass a specific browser choice or test filter.

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

Run a separately managed server

  1. Start the Angular application with the project’s chosen serve or preview command.

  2. Wait until the server is reachable at the base URL your test uses.

  3. Run the Selenium test process with Chrome and a compatible driver available.

  4. Stop the server after test completion, including on failure, using your shell, task runner, or CI job’s cleanup mechanism.

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

This split can make failures easier to diagnose: the server’s startup log is separate from WebDriver’s browser and test output. It also means the test runner must not race ahead while the Angular server is still compiling or starting.

Use CI’s headless browser configuration

Angular’s browser-testing documentation says CI uses headless mode by default and documents explicit chromeHeadless or chromiumHeadless names depending on the provider. These names belong to Angular browser-test configuration; they are not replacements for Selenium’s Chrome options when your Selenium test constructs its own WebDriver session. Check the setup used by your specific builder and CI provider at Angular testing.

Keep the same app URL strategy, browser/driver pairing, and selectors between local and CI runs where practical. If a particular CI image requires additional Chrome arguments, add only the flags required by that image; do not copy environment-specific flags into every setup by default.

Decide between local Chrome and remote execution

Arrangement Setup ownership Browser and OS coverage Parallel capacity Artifacts and cost
Local or CI-hosted Chrome You manage the browser, compatible driver, runtime image, and test process. Limited to browsers and operating systems you install in that environment. Constrained by the workers and resources you provision. Logs and files are available in your environment; infrastructure cost depends on the machine or CI plan.
Selenium Grid or hosted Selenium-compatible service Grid or provider manages remote session placement; you still configure and maintain the tests and capabilities. Can span remote machines and browser environments according to the Grid or provider configuration. Can support parallel sessions subject to available nodes, quotas, and provider capacity. Artifact access and pricing depend on the chosen deployment or provider; confirm their terms and retention settings.

Selenium documents remote Grid sessions and hosted providers such as Sauce Labs in its Remote WebDriver material. Remote execution is useful when local execution works and you need broader browser/OS coverage or parallel machines. It adds network, capability, and provider configuration to the failure surface, so first establish a reliable local run.

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

Angular’s CLI documentation lists integrations including WebdriverIO, Playwright, Cypress, Nightwatch, and Puppeteer. Select based on your existing Angular setup, language and runner ecosystem, selectors and debugging workflow, and whether you specifically need Selenium-compatible remote execution; this article’s WebDriver example is for Selenium rather than those alternative runners.

Troubleshoot common failures

ChromeDriver cannot start Chrome

Likely cause: Chrome is missing, the driver is unavailable, or the driver and browser versions are incompatible. Fix: verify the browser binary exists in the test environment, make the appropriate driver available to Selenium, and align the versions. Check CI logs for the actual browser and driver being used rather than assuming they match your laptop.

The test cannot connect to the Angular URL

Likely cause: the server has not started, is listening on another port or interface, or is not reachable from the browser session. Fix: confirm the URL from the same environment running Selenium and wait for server readiness before navigation. With remote Grid, remember that localhost refers to the machine hosting the browser session, not necessarily the machine running the test code.

An element lookup fails intermittently

Likely cause: the test queries before Angular has rendered the target, or the selected element is replaced during a state change. Fix: wait for the element’s meaningful state—located, visible, or enabled—using an explicit wait, then find it again after a rerender if needed. Replace fragile CSS paths with stable test or accessibility selectors.

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

The test passes locally but fails in headless CI

Likely cause: environment differences such as browser version, viewport, timing, fonts, missing dependencies, or a server readiness race. Fix: compare browser and driver versions, set a deliberate viewport when layout matters, wait on application state rather than fixed timing, and inspect browser and server logs. Add extra Chrome arguments only when the CI image’s requirements point to them.

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.

Chrome processes remain after a failed test

Likely cause: teardown is skipped when an assertion or navigation fails. Fix: put driver.quit() in finally or the framework’s guaranteed after-test hook, and make CI cleanup terminate any separately managed app server.

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

Performance, reliability, and cost considerations

Headless mode removes the need for a visible desktop, but it does not guarantee that a suite runs faster or more reliably. Runtime depends on application startup, the number and shape of tests, browser and CI resources, synchronization, and whether sessions are local or remote. Measure your own suite under the same browser image and concurrency you plan to use; there is no universal speed percentage for this setup.

For predictable runs, pin or deliberately update browser and driver versions together, keep test data and server startup repeatable, avoid arbitrary sleeps, capture failure logs or screenshots through your test framework, and limit parallel sessions to the resources your environment can support. Selenium Grid can distribute sessions across machines, but parallelism does not remove shared-state conflicts in the app or test data.

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

Or skip the browser setup

If you need a rendered website image rather than browser-driven interaction and assertions, ScreenshotNeo is a website screenshot API and MCP server. A single request returns a PNG, JPEG, WebP, or PDF; it is not a replacement for Selenium end-to-end behavior tests. Its clean-shot options accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture, with each step switchable. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf.

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

Replace YOUR_API_KEY and the target URL for your use. See the ScreenshotNeo API documentation for response formats and request options. ScreenshotNeo includes 1,000 shots per month on its free plan with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Does Selenium headless Chrome need a display server?

No. Headless Chrome runs without opening a visible browser window, which is why it can run in a CI environment without a desktop display.

Can Selenium test Angular without using `ng e2e`?

Yes. Start the Angular app separately, then navigate Selenium to its served base URL. The `ng e2e` route is for projects with an e2e target configured.

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.

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.