Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Configure headless mode on the browser’s options object, then pass that object to the matching Selenium WebDriver. Use --headless=new for current Chromium browsers (Chrome and Edge) and -headless for Firefox. The same pattern works in CI because no visible browser window is created.
What headless mode changes
A headless browser runs the normal browser engine without displaying a window. Selenium can still navigate, execute JavaScript, locate elements, submit forms, save screenshots and produce page output. Headless is useful on servers, containers and continuous-integration workers that have no desktop session.
Headless is a launch setting, not a single Selenium switch shared by every browser. Each driver receives its own options class and browser-specific argument. The examples below use Selenium’s current Python API, whose supported Python versions are listed in the official API documentation.
Free tools Windows power users keep installed
One-click scans. No signup required.
Install Selenium and prepare the browsers
- Install Python 3.10 or newer, as specified by Selenium’s Python API documentation.
- Install Selenium in the environment that will run your script:
python -m pip install -U selenium - Install the browser you intend to automate. Chrome, Edge or Firefox must be available to the account running the script.
- Let Selenium Manager resolve a compatible driver in ordinary installations. Selenium documents this automatic management for most supported platforms and browsers at Selenium Manager.
On Windows, Selenium Manager’s automatic Edge installation requires administrator permissions. If a locked-down build cannot install or find Edge, install Edge beforehand or provide a driver through your organization’s approved deployment process.
#1 Best Overall
Chrome in headless mode
Use ChromeOptions and add the current Chromium argument --headless=new. Chrome introduced the newer headless implementation in Chrome 109; browser behavior can change, so check current Chrome release notes when pinning a production image. Selenium’s explanation of the transition is available in Headless is Going Away!.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
options = ChromeOptions()
options.add_argument("--headless=new")
browser = webdriver.Chrome(options=options)
try:
browser.get("https://example.com")
print(browser.title)
finally:
browser.quit()
Do not use the removed convenience pattern options.headless = True in new code. Selenium deprecated that setter in 4.8.0 and removed it in 4.10.0; launch arguments are the supported approach.
Edge (Chromium) in headless mode
Edge’s Selenium options inherit Chromium options, so the argument is also --headless=new. Pass an EdgeOptions instance to webdriver.Edge.
Recommended Free Tools
from selenium import webdriver
from selenium.webdriver.edge.options import Options as EdgeOptions
options = EdgeOptions()
options.add_argument("--headless=new")
browser = webdriver.Edge(options=options)
try:
browser.get("https://example.com")
print(browser.title)
finally:
browser.quit()
The relevant inheritance is shown in Selenium’s Edge options source. If Selenium Manager attempts to install Edge on Windows, remember the administrator-permission limitation described above.
Firefox in headless mode
Firefox uses the single-dash argument -headless. Selenium’s Firefox guide requires Firefox 78 or later for Selenium 4 and recommends the latest compatible geckodriver.
Rank #2
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
options = FirefoxOptions()
options.add_argument("-headless")
browser = webdriver.Firefox(options=options)
try:
browser.get("https://example.com")
print(browser.title)
finally:
browser.quit()
See the Firefox-specific Selenium documentation for browser-specific capabilities.
One script that selects a browser
This example keeps setup in one function and guarantees that every session is closed. The code is illustrative; verify it in your target browser and operating-system image before relying on it in production.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions
def create_driver(name: str):
name = name.lower()
if name == "chrome":
options = ChromeOptions()
options.add_argument("--headless=new")
return webdriver.Chrome(options=options)
if name == "edge":
options = EdgeOptions()
options.add_argument("--headless=new")
return webdriver.Edge(options=options)
if name == "firefox":
options = FirefoxOptions()
options.add_argument("-headless")
return webdriver.Firefox(options=options)
raise ValueError("browser must be chrome, edge, or firefox")
browser = create_driver("chrome")
try:
browser.get("https://example.com")
print(browser.title)
finally:
browser.quit()
Useful options for real test runs
Window size and screenshots
Headless sessions still have a viewport. Set it explicitly when responsive layout matters, then capture an image for diagnostics:
options.add_argument("--window-size=1440,1000")
browser.get("https://example.com")
browser.save_screenshot("example.png")
Use the equivalent argument on Chromium browsers. For Firefox, set the window after startup when needed:
browser.set_window_size(1440, 1000)
Waiting for dynamic pages
Headless does not make asynchronous content instantly available. Prefer an explicit wait for a meaningful condition rather than a fixed sleep:
Rank #3
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser.get("https://example.com/dashboard")
WebDriverWait(browser, 20).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "main"))
)
Other Chromium flags
Some container images need additional operating-system configuration (for example, writable temporary storage or a virtual display policy). Add only flags required by your environment and security review; indiscriminately copying blog-post flag lists can hide genuine sandbox or permission problems.
Safari, WebKit and Internet Explorer status
Safari
Selenium lists Safari among supported Python browsers and exposes Safari options, but the material available here does not establish an authoritative, version-specific Safari headless argument. Do not promise that the Chrome or Firefox flags work on Safari. Confirm the exact macOS and Safari release in Apple/WebKit documentation before designing a headless Safari pipeline.
WebKitGTK and WPEWebKit
The Selenium Python API lists WebKitGTK and WPEWebKit as supported browser targets. Their launch configuration is platform-specific and is not interchangeable with Chrome’s --headless=new flag.
Internet Explorer
Standalone Internet Explorer is not a current headless peer. Selenium ended official standalone IE support in June 2022. The remaining IE driver scenario is Microsoft Edge running IE Compatibility Mode, as described in Selenium’s IE documentation.
Troubleshooting headless sessions
“Unable to obtain driver” or browser-version errors
- Confirm the browser executable is installed for the same user that runs Python.
- Upgrade Selenium so Selenium Manager is current.
- Check that a corporate proxy, firewall or endpoint policy is not blocking driver downloads.
- For Firefox, use Firefox 78 or newer with a current geckodriver, as Selenium recommends.
The page is blank or elements cannot be located
- Wait for a specific element or state; headless timing can expose an existing race in the test.
- Set a realistic viewport because responsive breakpoints may render a different DOM.
- Save a screenshot and page source immediately before the failing lookup.
- Check whether a cookie banner, login redirect, bot challenge or required geolocation is changing the page.
Chrome or Edge exits immediately in a container
- Read the browser and driver logs for sandbox, shared-memory and permission errors.
- Give the process writable temporary space and adequate shared memory according to your container policy.
- Use only security-approved flags; disabling browser isolation can create a serious risk.
Safari does not start headless
Treat this as an unresolved capability question rather than substituting a Chromium flag. Verify support for the exact Safari/macOS combination, or run Safari with its supported visible-session workflow.
Rank #4
Reliability, speed and cost considerations
Headless removes display overhead but does not guarantee a fixed speed improvement. Network latency, JavaScript work, page size, CPU limits and waits usually dominate runtime. Reuse a driver for a sequence of pages when isolation permits, and always call quit() in a finally block. Pin browser versions in CI when reproducibility matters, then update them deliberately and review layout or WebDriver changes.
There is no Selenium license fee for these examples, but your infrastructure still pays for CPU, memory, browser images and CI minutes. A failed startup should be diagnosed before increasing timeouts; longer waits cannot repair a missing driver or incompatible browser.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
For a server-side screenshot rather than interactive WebDriver control, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP or PDF, with options for full-page captures, CSS selectors, device presets, dark mode, custom JavaScript, waits, cookies, headers, blocking rules and more.
Cookie and consent banners, newsletter popups and chat widgets are removed before the shot. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and whether it was billed. Its MCP tools—take_screenshot, get_page_info and capture_pdf—let Claude, Cursor and other MCP clients request captures.
Example cURL (see the ScreenshotNeo documentation):
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}`);
The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account.
Best Value
FAQ
Can I run multiple browsers in the same Python process?
Yes. Create separate driver objects with separate options, and quit each one independently. Parallel sessions need enough CPU, memory and isolated test data.
Does headless mode bypass CAPTCHAs?
No. Headless only changes window presentation. Sites can still require authentication, consent, JavaScript checks or CAPTCHA interaction.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Why is my headless layout different?
Viewport dimensions, device-pixel settings, browser version, fonts and responsive breakpoints can all change rendering. Set the viewport explicitly and compare screenshots from the same pinned environment.
Frequently Asked Questions
Can I run multiple browsers in the same Python process?
Yes. Create separate driver objects with separate options, and quit each one independently. Parallel sessions need enough CPU, memory and isolated test data.
Does headless mode bypass CAPTCHAs?
No. Headless only changes window presentation. Sites can still require authentication, consent, JavaScript checks or CAPTCHA interaction.
Why is my headless layout different?
Viewport dimensions, device-pixel settings, browser version, fonts and responsive breakpoints can all change rendering. Set the viewport explicitly and compare screenshots from the same pinned environment.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →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.

