Selenium stealth: setup and limits.
selenium-stealth hides automation tells in Selenium’s Chrome
such as navigator.webdriver. How to install and call it, what
each option does, how it holds up in 2026, and what to do about hCaptcha.
What selenium-stealth is
Selenium drives a real Chrome, but an automated one reports itself in ways
a page script can read: navigator.webdriver is
true, and headless Chrome puts HeadlessChrome in
its user agent. selenium-stealth injects patches into every
page before the site’s own scripts run, so those values read more like a
normal browser’s. Its README calls it a re-implementation of the Node
plugin
puppeteer-extra-plugin-stealth,
and every JavaScript file it ships but one opens with a link to the
matching file in that plugin. As read from PyPI and GitHub on 2 November
2026:
- Install name:
pip install selenium-stealth, imported asselenium_stealth. - Author: Dipraj Patra (
diprajpatraon GitHub). MIT licence. - Latest release: 1.0.6, uploaded to PyPI on 5 November 2020.
- Last commit on
main: 5 November 2020. - GitHub: 739 stars and 37 open issues and pull requests; not archived.
- Browser: Chrome only. The driver must be a
selenium.webdriver.Chrome.
The project lives at github.com/diprajpatra/selenium-stealth and the package at pypi.org/project/selenium-stealth. All seven releases, 1.0.0 to 1.0.6, went out between 2 and 5 November 2020.
Install and a quick start
pip install selenium-stealth
That pulls in Selenium as well. Build a Chrome driver, call
stealth() on it once, then browse as usual:
from selenium import webdriver
from selenium_stealth import stealth
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(options=options)
stealth(
driver,
languages=["en-US", "en"],
vendor="Google Inc.",
platform="Win32",
webgl_vendor="Intel Inc.",
renderer="Intel Iris OpenGL Engine",
fix_hairline=True,
)
driver.get("https://your-site.example/")
print(driver.execute_script("return navigator.webdriver")) # None (True without stealth)
print(driver.execute_script("return navigator.userAgent")) # "... Chrome/..." not "HeadlessChrome"
driver.quit()
We ran exactly this on 2 November 2026 with Python 3.13, Selenium 4.52.0
and headless Chrome 156. Without stealth(),
navigator.webdriver came back True and the user
agent said HeadlessChrome. With it, Python got
None (the page sees undefined) and the user
agent said Chrome. Two things in older tutorials and in the
README’s own example will trip you up:
- Leave out
platformand it crashes.stealth(driver)with noplatformraisedInvalidArgumentException: invalid argument: Invalid parameterson Chrome 156, because it passes Chrome’s user-agent override a platform with no value. Any value fixes it. -
executable_pathis gone. The README builds the driver withwebdriver.Chrome(options=options, executable_path=...). Selenium 4.52 rejects that withTypeError: ... unexpected keyword argument 'executable_path'. Drop it (Selenium found chromedriver on its own in our run), or pass the path through aServiceobject (selenium.webdriver.chrome.service).
Its options
stealth() takes the driver and eight keyword arguments. The
README’s Args block shows a fixed Chrome 83 user agent and
"Win32" as defaults; the code that ships in 1.0.6 defaults
both to None:
stealth(
driver, # must be selenium.webdriver.Chrome
user_agent=None,
languages=["en-US", "en"],
vendor="Google Inc.",
platform=None,
webgl_vendor="Intel Inc.",
renderer="Intel Iris OpenGL Engine",
fix_hairline=False,
run_on_insecure_origins=False,
) | Argument | Default in the code | What it sets |
|---|---|---|
user_agent | None | The user agent. With None it keeps Chrome’s own and swaps HeadlessChrome for Chrome |
languages | ["en-US", "en"] | navigator.languages |
vendor | "Google Inc." | navigator.vendor |
platform | None | navigator.platform. Pass it: see the error above |
webgl_vendor, renderer | "Intel Inc.", "Intel Iris OpenGL Engine" | The WebGL vendor and renderer strings a page can read |
fix_hairline | False | Patches the element height Modernizr’s hairline test measures |
run_on_insecure_origins | False | Also adds the chrome.runtime patch on plain http pages |
The README’s values describe a Windows PC with Intel graphics. On our
Mac run they gave a user agent saying Macintosh next to a
navigator.platform of Win32, and WebGL said
Intel Iris on an Apple chip. Set platform,
webgl_vendor and renderer to match the machine
and user agent you actually run on.
What it patches
Most patches are small scripts registered with Chrome’s
Page.addScriptToEvaluateOnNewDocument
command, so they run before the page’s own code; the user agent,
platform and Accept-Language go through Chrome’s
Network.setUserAgentOverride instead. Version 1.0.6 ships
these:
- Automation flag:
navigator.webdriver, which it deletes rather than sets tofalse. - Identity strings: the user agent,
navigator.platform,navigator.vendorandnavigator.languages. - Browser objects headless Chrome lacks or fakes badly:
window.chrome(app,csi,loadTimes,runtime),navigator.plugins,navigator.permissionsand media codecs. - Rendering and window: the WebGL vendor and renderer,
window.outerWidthandouterHeight, and the optional hairline fix. - Frames:
iframe.contentWindow, patched so frames built withsrcdocdo not give automation away.
How it holds up in 2026
The patches date from late 2020 and Chrome has changed since. On Chrome 156 we measured these gaps, each a value a page script can read:
-
navigator.webdriveris missing, not false. With stealth,'webdriver' in navigatorwasfalse. Chrome itself always has the property; plain Selenium reported it present. - Client hints disappear. Plain Selenium sent a
Sec-CH-UAheader naming Chromium and Google Chrome, andnavigator.userAgentData.brandslisted them. With stealth the header was gone and the brands list was empty. - New tabs are not patched. A tab opened after
stealth()withdriver.switch_to.new_window("tab")readnavigator.webdriverTrueandHeadlessChromeagain. That is open issue #31, filed in April 2022. - Chrome only. Any driver that is not a
selenium.webdriver.Chromegets aValueError. Firefox and Remote WebDriver support are open requests.
The README still says the package “passes all public bot tests”, can “do google account login” and helps keep “a normal reCAPTCHA v3 score”. Those lines were written in 2020 and we have not tested them. The open issues include reports that it stopped working on particular sites, and a pull request from January 2021 titled “Bring up to date with puppeteer-extra-plugin-stealth” is still open.
Does selenium-stealth get past hCaptcha?
A stealth patch changes what your browser says about itself. It can make a visit look less like automation, and that is one of several things that decide whether a site’s hCaptcha shows a challenge at all; why am I getting hCaptcha covers the others, starting with the reputation of your IP address, which no browser patch changes.
Once a challenge does appear, stealth has nothing more to offer. The site
accepts the form only with a valid token in the
h-captcha-response field, a
P1_ string its server checks with hCaptcha before it lets the
request through. Invisible hCaptcha needs that token too, even when no
puzzle is shown. A browser patch does not produce one.
Where NoneCap fits
NoneCap is an hCaptcha solving API. Keep stealth for the rest of your
Selenium run, and when a page has hCaptcha, send its sitekey
and url to NoneCap, get a P1_ token back, put it
in the form and submit. Failed, cancelled and expired solves are never
charged. With the nonecap Python SDK
(pip install nonecap),
nc.solve() waits for the token in one call:
import os
from nonecap import NoneCap
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium_stealth import stealth
nc = NoneCap(api_key=os.environ["NONECAP_KEY"])
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(options=options)
# match your OS: "MacIntel", "Linux x86_64"
stealth(driver, platform="Win32", fix_hairline=True)
driver.get("https://your-site.example/signup")
sitekey = driver.find_element(By.CSS_SELECTOR, "[data-sitekey]").get_attribute("data-sitekey")
token = nc.solve(type="hcaptcha", sitekey=sitekey, url=driver.current_url).token
driver.execute_script("""
for (const name of ["h-captcha-response", "g-recaptcha-response"]) {
const el = document.querySelector(`textarea[name="${name}"]`);
if (el) el.value = arguments[0];
}
""", token)
driver.find_element(By.CSS_SELECTOR, "button[type=submit]").click()
driver.quit()
The Selenium guide covers the rest:
reading a sitekey that is not in the DOM, invisible widgets and their
callbacks, enterprise (rqdata) sitekeys, and the SDK’s error
types. Every field and status is in the
API reference, and the
Playwright stealth guide
is the same walk-through for Playwright. NoneCap solves
hCaptcha only; it does not help with reCAPTCHA,
Turnstile or other CAPTCHAs.
Last updated November 2026.
Frequently asked
What is selenium-stealth?
navigator.webdriver and HeadlessChrome in the user agent. Its author, Dipraj Patra, describes it as a re-implementation of the Node plugin puppeteer-extra-plugin-stealth. It works only with Chrome.How do I install selenium-stealth?
pip install selenium-stealth; it installs Selenium too. Then call stealth(driver, platform="Win32") on a webdriver.Chrome before you open any page. The package imports as selenium_stealth, with an underscore.Is selenium-stealth still maintained?
main branch is from the same day. The repository is not archived and has 37 open issues and pull requests. It still installs and runs: we ran it with Selenium 4.52.0 and Chrome 156.Why does stealth(driver) raise InvalidArgumentException?
platform, it sends Chrome a user-agent override with no platform value, and Chrome 156 refused it with “invalid argument: Invalid parameters” in our run. Pass a value, for example platform="Win32", ideally one that matches the operating system in your user agent.Does selenium-stealth work with Firefox, Edge or a remote WebDriver?
stealth() checks that the driver is a selenium.webdriver.Chrome and raises ValueError for anything else. Firefox and Remote WebDriver support are open feature requests on its GitHub.selenium-stealth or undetected-chromedriver?
selenium.webdriver.Chrome. Neither one returns an hCaptcha token, so a site that shows hCaptcha still needs one either way.Does selenium-stealth bypass CAPTCHA?
h-captcha-response, and the patch does not provide one. NoneCap returns that token for hCaptcha.