Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteTo run Selenium without opening a visible browser window, enable headless mode in the browser options before creating the WebDriver. In Chrome with Python, add --headless=new, set a viewport if page layout matters, and call driver.quit() in a finally block. Headless mode still renders pages and runs browser code; it simply does not display the normal graphical window.
Run Chrome headlessly with Python
Install the Selenium Python binding in the environment where the script will run:
python -m pip install selenium
Then use Chrome options to enable headless mode before constructing the driver:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless=new")
options.add_argument("--window-size=1920,1080")
driver = webdriver.Chrome(options=options)
try:
driver.get("https://example.com")
print(driver.title)
finally:
driver.quit()
The explicit viewport makes responsive pages more predictable: a page can show different elements at a mobile-sized width than it does at desktop width. Change the dimensions to suit the layout your test expects. The Selenium Chrome documentation lists --headless=new among commonly used Chrome arguments and demonstrates passing an options object to webdriver.Chrome.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
The try/finally structure closes the browser even when navigation or an assertion raises an exception. Continue using Selenium’s normal navigation, waits, element interactions, assertions, and screenshot methods; headless mode changes how the window is displayed, not the basic WebDriver workflow.
Run Chrome headlessly with Java
Pass the headless argument through ChromeOptions before creating the ChromeDriver instance:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class HeadlessExample {
public static void main(String[] args) {
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless=new");
WebDriver driver = new ChromeDriver(options);
try {
driver.get("https://example.com");
System.out.println(driver.getTitle());
} finally {
driver.quit();
}
}
}
Use the browser-specific options class for another browser. For example, Firefox and Edge have their own options classes and configuration details; do not assume Chrome command-line switches apply to them unchanged.
What headless mode changes—and what it does not
Headless means the browser does not show its ordinary graphical window. It does not mean that Selenium skips rendering or that page JavaScript stops running. Chrome for Developers says that in Chrome 112, headless mode was updated so Chrome creates platform windows without displaying them; current headless mode shares Chrome’s code. The documentation page was last updated October 21, 2024. See Chrome’s headless mode documentation.
Rank #2
This distinction matters when diagnosing a test. A headless run can still be affected by page load timing, responsive breakpoints, browser compatibility, network conditions, and application behavior. If a test behaves differently from a visible run, compare the viewport and browser configuration before assuming headless mode omitted the page.
Set up Selenium and its browser driver
Install Selenium and a browser
Install the language binding your script uses, and make sure a supported browser is installed in the machine, container, or CI runtime. Selenium cannot launch a browser that is absent from the environment.
Let Selenium Manager resolve the driver
In current Selenium releases, Selenium Manager is shipped with Selenium and is invoked by the bindings when a driver is unavailable. It can discover browser versions, resolve compatible drivers, download them, and cache them. Selenium Manager supports Chrome, Firefox, and Edge. See Selenium Manager documentation.
Manage ChromeDriver manually only when needed
If your environment requires a manually managed ChromeDriver, keep its major version aligned with the installed Chrome major version. A mismatch can prevent the session from starting. Check the actual browser and driver versions in the same runtime that launches the test, not just on a developer workstation.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRank #3
Use headless mode in a repeatable test
- Choose the browser and environment. Confirm the browser is installed in the host or CI image where the job runs.
- Configure browser options. Add
--headless=newfor Chrome and set a consistent window size when the test depends on layout. - Create the WebDriver. Pass the configured options to the driver constructor.
- Wait for the application state you need. Prefer explicit waits for a particular element or condition over assuming the page is ready immediately after navigation.
- Capture useful failure evidence. Save a screenshot or driver logs when a test fails, and use the same viewport and browser setup when reproducing it visibly.
- Always clean up. Call
quit()in a cleanup path so browser processes are not left behind after a failed test.
Choose local, remote, or managed execution
Headless mode is a browser display setting, not an execution service. You can run the browser locally or in CI, or connect Selenium to a remote browser environment. The right choice depends on where the browser and test need to run.
- Local execution is straightforward for development and quick checks. A visible run is often easier while debugging; headless mode is useful for unattended scripts.
- CI execution makes unattended runs practical, but the CI image must include a compatible browser setup and provide enough diagnostics to investigate failures.
- Remote execution separates the test process from the browser host. Selenium’s standard browser options still matter, but remote infrastructure adds its own availability, configuration, and network considerations.
There is no universal speed or resource-saving figure established by the cited documentation for headless Selenium. Treat performance as specific to the browser, page, runtime, and workload; measure your own job rather than assuming headless mode guarantees a particular improvement.
Why headless Selenium fails in CI
Session creation fails or reports a version mismatch
Compare the installed Chrome and ChromeDriver major versions. If a stale manually configured driver is taking precedence, remove that path or configuration and allow Selenium Manager to resolve the driver when appropriate.
Expected elements appear to be missing
Set an explicit window size and inspect the page’s responsive behavior at that width. Then add an explicit wait for the element or state the test needs. A successful navigation call does not necessarily mean a client-rendered page has finished displaying the target content.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #4
The job crashes only in CI
Enable ChromeDriver service logs and inspect them alongside the CI job output. Selenium’s Chrome documentation shows Python service logging configuration:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
options = Options()
options.add_argument("--headless=new")
options.add_argument("--window-size=1920,1080")
service = Service(log_output="chromedriver.log")
driver = webdriver.Chrome(service=service, options=options)
try:
driver.get("https://example.com")
print(driver.title)
finally:
driver.quit()
Check the log for startup or session errors, then verify that the CI runtime has the intended browser, driver resolution, and access to the page being tested. The Chrome browser documentation covers options and service configuration.
An old tutorial sets options.headless = True
Current Selenium Chrome guidance favors passing the browser command-line argument so the selected Chromium headless mode is explicit. Use options.add_argument("--headless=new") rather than relying on older examples without checking whether their API matches your installed Selenium version.
You cannot see what the browser did
Temporarily remove the headless argument and rerun with the same viewport and profile settings. You can also capture a screenshot and retain driver logs during the headless run. Matching the configuration makes the visible reproduction more useful than changing several settings at once.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
Headless Selenium versus a screenshot API
Use Selenium when the task needs browser interactions or test assertions: for example, clicking through an application, checking a flow, or validating an element after a state change. If the goal is simply to obtain a page screenshot or PDF by URL, a screenshot API can avoid maintaining a browser-and-driver setup. ScreenshotNeo is a website screenshot API and MCP server; it removes known consent banners, newsletter popups, and chat widgets before capture, and bills only clean shots.
Or skip the browser setup
A single GET request can return a screenshot. Get an API key, then run this cURL example; replace the target URL as needed. The response is saved as WebP:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for parameters and response details. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents use screenshot tools, and the Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo free.
Cost, reliability, and practical limits
A locally run Selenium script uses the browser and driver resources of the machine or CI job that runs it. Budget for those runtime resources and for maintenance of the browser environment. Selenium Manager reduces manual driver management, but it does not remove the need for a browser or eliminate network and runtime failures.
Recommended Free Tools
For repeated test runs, make the environment reproducible: record the Selenium binding version and browser setup, set a fixed viewport for layout-sensitive tests, use explicit waits, and retain logs or screenshots for failed jobs. These practices make failures easier to distinguish among application issues, browser startup problems, and differences in the CI environment.
Frequently Asked Questions
Does headless Selenium need a browser installed?
Yes. The browser must be installed in the runtime that launches WebDriver; headless mode only suppresses the normal visible window.
Can I use headless mode with Firefox or Edge?
Yes, Selenium supports those browsers, but configure them with their own browser options class and browser-specific settings rather than assuming Chrome flags are interchangeable.
Does headless mode make Selenium tests faster?
The cited documentation establishes how headless mode works, not a universal speed improvement. Performance depends on the browser, page, environment, and workload.
Quick Recap
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.

