{"id":8631,"library":"selenium-stealth","title":"Selenium Stealth","description":"Selenium Stealth is a Python library designed to make Selenium WebDriver more stealthy, aiming to bypass anti-bot detection systems on websites. It achieves this by modifying various browser properties and behaviors that typically reveal automated browsing, such as the `navigator.webdriver` flag, user-agent, and WebGL fingerprints. The library currently supports Chrome/Chromium and is at version 1.0.6. While still functional for many use cases, its last update on PyPI was in November 2020, and there is an actively maintained fork, `stealthenium`, for those seeking ongoing development.","status":"maintenance","version":"1.0.6","language":"en","source_language":"en","source_url":"https://github.com/diprajpatra/selenium-stealth","tags":["selenium","web scraping","anti-bot","stealth","automation","chrome"],"install":[{"cmd":"pip install selenium-stealth","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required for browser automation.","package":"selenium","optional":false}],"imports":[{"symbol":"stealth","correct":"from selenium_stealth import stealth"}],"quickstart":{"code":"from selenium import webdriver\nfrom selenium.webdriver.chrome.service import Service\nfrom selenium.webdriver.chrome.options import Options\nfrom selenium_stealth import stealth\nimport time\n\n# Set up Chrome options\nchrome_options = Options()\nchrome_options.add_argument(\"start-maximized\")\nchrome_options.add_experimental_option(\"excludeSwitches\", [\"enable-automation\"])\nchrome_options.add_experimental_option('useAutomationExtension', False)\n\n# Configure ChromeDriver service (optional for Selenium 4.6+ if Chrome is in PATH)\n# If ChromeDriver is not in PATH, uncomment and set executable_path\n# service = Service(executable_path='/path/to/chromedriver')\n# driver = webdriver.Chrome(service=service, options=chrome_options)\n\n# For Selenium 4.6+ and Chrome in PATH, direct initialization is often sufficient\ndriver = webdriver.Chrome(options=chrome_options)\n\n# Apply stealth settings\nstealth(\n    driver,\n    languages=[\"en-US\", \"en\"],\n    vendor=\"Google Inc.\",\n    platform=\"Win32\",\n    webgl_vendor=\"Intel Inc.\",\n    renderer=\"Intel Iris OpenGL Engine\",\n    fix_hairline=True,\n)\n\nprint(\"Navigating to a test site...\")\ndriver.get(\"https://bot.sannysoft.com/\") # A common site to test bot detection\ntime.sleep(5) # Give some time for the page to load and scripts to run\nprint(f\"Page title: {driver.title}\")\n\n# Add your scraping logic here\n\ndriver.quit()\nprint(\"Browser closed.\")","lang":"python","description":"This quickstart initializes a Chrome WebDriver instance with common options to hide automation indicators, then applies the `selenium-stealth` modifications. It navigates to a known bot detection test site (`sannysoft.com`) to demonstrate its effect. Ensure you have `chromedriver` compatible with your Chrome browser version, either in your system PATH or specified via `Service(executable_path=...)`."},"warnings":[{"fix":"Consider `pip install stealthenium` and updating your imports and usage according to its documentation.","message":"The `selenium-stealth` project has not received updates on PyPI since November 2020 and its maintenance status is considered inactive. A more actively maintained fork, `stealthenium`, is available and explicitly states it's a fork of this unmaintained project. Consider migrating to `stealthenium` for ongoing support and updates.","severity":"deprecated","affected_versions":"<=1.0.6"},{"fix":"Ensure you are using `selenium.webdriver.Chrome` with compatible Chrome browser and ChromeDriver versions.","message":"Selenium Stealth currently only supports Chrome/Chromium browsers. It does not provide stealth capabilities for Firefox, Edge, or other browsers.","severity":"gotcha","affected_versions":"*"},{"fix":"For highly resistant websites, consider running in headful mode (without `--headless`), adding realistic delays (`time.sleep()`), simulating mouse movements, and using rotating proxies.","message":"While `selenium-stealth` enhances anonymity, running browsers in headless mode (`--headless` Chrome option) can still be a strong indicator of automation and may lead to detection on sophisticated anti-bot sites.","severity":"gotcha","affected_versions":"*"},{"fix":"Rely on `selenium-stealth`'s default parameter values, or be extremely careful when customizing parameters like `languages`, `vendor`, `platform`, `webgl_vendor`, and `renderer` to ensure they form a consistent, realistic browser fingerprint.","message":"Attempting to manually spoof browser properties like `User-Agent` via Chrome options without ensuring consistency with other `navigator` properties (e.g., `platform`) can lead to immediate bot detection. `selenium-stealth` handles many of these internally.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Update your ChromeDriver to match your Chrome browser version. Check `chrome://settings/help` for your Chrome version, then download the corresponding ChromeDriver from the official site. Also, ensure sufficient system resources and add `--no-sandbox` if running in a containerized environment.","cause":"This typically indicates an incompatibility between your Chrome browser version and the ChromeDriver executable version, or issues with Chrome launching (e.g., insufficient memory, corrupted user profile, or sandbox issues in Docker).","error":"selenium.common.exceptions.SessionNotCreatedException: Message: session not created: DevToolsActivePort file doesn't exist"},{"fix":"Beyond `selenium-stealth`, consider: 1) Using `undetected_chromedriver` (a separate project designed for this purpose). 2) Adding random delays (`time.sleep()`) and simulating human-like interactions (scrolls, mouse movements). 3) Rotating IP addresses with proxies. 4) Avoiding headless mode or configuring it very carefully. 5) Maintaining browser profiles (cookies) to build 'trust'.","cause":"While `selenium-stealth` addresses many common detection vectors (like `navigator.webdriver`), advanced anti-bot systems employ more sophisticated techniques, including analyzing behavior patterns (speed, mouse movements), IP reputation, CAPTCHA challenges, and complex browser fingerprinting beyond what `selenium-stealth` alone can spoof.","error":"Websites are still detecting my Selenium script as a bot, despite using selenium-stealth."},{"fix":"Implement `time.sleep()` for random delays between actions. Use Selenium's explicit waits (`WebDriverWait` and `expected_conditions`) to ensure elements are present, visible, and clickable before interacting with them. Mimic human scrolling behavior.","cause":"Even with stealth, rapid, robotic interactions or failure to wait for dynamic content to load can trigger anti-bot measures or simply cause race conditions in your script. Websites expect human-like interaction speeds.","error":"I get inconsistent results or elements not found when rapidly interacting with a page after applying stealth."}]}