Skip to content

[🐛 Bug]: Chrome Extention is not working with selenium #16103

@Kushalinfox

Description

@Kushalinfox

Description

When using --load-extension to load a Chrome extension from an unpacked folder (e.g., ProtonVPN), Selenium launches Chrome but the extension UI does not appear or behave as expected, even though the path is valid and works manually via chrome://extensions.

Expected Behavior
Chrome should launch with the ProtonVPN extension loaded and visible in the extension bar.
The extension should behave as it does when loaded manually via Chrome.
User should be able to navigate to chrome-extension:///popup.html and interact with it.

Actual Behavior
Browser launches, but the extension:
Does not appear in the toolbar
Sometimes fails silently or does not initialize
Has no visible UI even when navigating to known internal URLs like popup.html
Works fine when added manually to Chrome via chrome://extensions

Tried Workarounds
Using .add_extension() with .crx version
Stripping flags down to minimal set
Using --disable-blink-features=AutomationControlled or useAutomationExtension = False
Verified the extension loads manually
Tested other extensions (same behavior)

Notes
The issue occurs only in automated WebDriver context
Might be a bug in how Selenium invokes Chrome with unpacked extensions

Reproducible Code

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os

EXTENSION_DIR = r"C:\Users\Infox\AppData\Local\Google\Chrome\User Data\Profile 3\Extensions\majdfhpaihoncoakbjgbdhglocklcgno\3.6.3_0"
WEB_URL = "https://chromewebstore.google.com/detail/free-vpn-for-chrome-vpn-p/majdfhpaihoncoakbjgbdhglocklcgno"

chrome_options = Options()
chrome_options.add_argument(f"--load-extension={os.path.abspath(EXTENSION_DIR)}")

# General Chrome flags
chrome_options.add_argument("--developer-mode")
chrome_options.add_argument("--enable-extensions")
chrome_options.add_argument("--extensions-on-chrome-urls")
chrome_options.add_argument("--disable-web-security")
chrome_options.add_argument("--allow-running-insecure-content")
chrome_options.add_argument("--enable-logging")
chrome_options.add_argument("--enable-ui-devtools")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("start-maximized")
chrome_options.add_argument("disable-infobars")
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("--allow-chrome-scheme-url")

# Anti-detection tweaks
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])

driver = webdriver.Chrome(options=chrome_options)
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")

driver.get(WEB_URL)

ℹ️ Last known working version: 4.34.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-pyPython BindingsD-chromeI-defectSomething is not working as intendedI-regressionSomething was working but we "fixed" itOS-windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions