selenium: [🐛 Bug]: Chrome team removes `--load-extension` switch on Chrome builds

Description

They remove --load-extension that cause .AddExtensions() and other similar method broken

their commit https://chromium.googlesource.com/chromium/src/+/290ed8046692651ce76088914750cb659b65fb17%5E%21/chrome/browser/extensions/extension_service.cc

Version affected: Chrome 137

Reproducible Code

var options = new ChromeOptions();
options.AddExtensions(_extensionsPath);
var driver = new ChromeDriver(options);

Debugging Logs

[13564:10684:0524/222309.634:WARNING:chrome\browser\extensions\extension_service.cc:359] --load-extension is not allowed in Google Chrome, ignoring.

ℹ️ Last known working version: it broke on Chrome 137, worked on 136 and below

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 49 (23 by maintainers)

Most upvoted comments

If you are using JavaScript try this

// Load chrome options let options = new chrome.Options(); options.addExtensions(extensionPath); options.addArguments(“–disable-features=DisableLoadExtensionCommandLineSwitch”);

// Initialize the WebDriver
const driver = new Builder()
    .forBrowser('chrome')
    .setChromeOptions(options)
    .build();

hah… someone just reported that this can be undone with this flag:

--disable-features=DisableLoadExtensionCommandLineSwitch

I just verified you can still use the old way of loading extensions if you start Chrome using this flag.

Should we add this by default to our Chrome Options? or just update the documentation that this is a workaround?

@oliverdunk is this going to remain working like this?

You will need to use BiDi’ to add extensions. Support for that will land in the next releases.

I have confirmed that the following code works to load an unpacked Chrome extension:

var options = new ChromeOptions(); options.AddArgument(“–load-extension=” + extensionPath);//Load unpacked extension options.AddArgument(“–disable-features=DisableLoadExtensionCommandLineSwitch”); var driver = new ChromeDriver(options);

Will this continue to work in the future, or is it just a temporary workaround?

I confirm that it works

c# example

var options = new ChromeOptions();
options.AddExtensions(_extensionsPath);
options.AddArgument("--disable-features=DisableLoadExtensionCommandLineSwitch");
var driver = new ChromeDriver(options);

@oliverdunk is this going to remain working like this?

This is part of the feature flag system we use to launch features. Unfortunately, that means it will go away once we are confident we no longer need a killswitch (usually they are around for no more than a few Chrome milestones).

Given that, I don’t think this would be a good thing to document. It is only a temporary workaround and it is expected to break in the future at which point there would be the same issue.

how can I install the unpacked extension using bidi with the latest selenium?

@nithikalisamy Here is a sample python script:

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

options = Options()
options.enable_bidi = True

# options.enable_webextensions = True  # this option is available from selenium 4.34 only and adds the below 2 flags automatically
options.add_argument("--remote-debugging-pipe") # this will disable CDP
options.add_argument("--enable-unsafe-extension-debugging")

driver = webdriver.Chrome(options=options)

extension_path = "/path/to/extension"
extension_result = driver.webextension.install(path=extension_path)
print(extension_result)

# Do stuff...

# Uninstall extension
driver.webextension.uninstall(extension_result)
driver.quit()

Do note that adding the --remote-debugging-pipe flag will disable CDP functionalities (restriction from chrome).

@Methuselah96

https://www.selenium.dev/documentation/webdriver/troubleshooting/logging/

Note that if Chrome is installed and found on your PATH, it will pick that up first. You can override that with the environment variable SE_FORCE_BROWSER_DOWNLOAD=true.

@caeduardo99 The workaround for disabling the flag removal is available now. It’s not a fix or change in Selenium.

@seleniumghost if you have complaints about the chrome/chromedriver development or release process, raise them with Google or the Chromium project… they don’t belong here.

Thank you for all this information.

(This is the 2nd time now within some weeks where a change in productional Chrome/chromedriver stops us from updating it in automated testing environments. First was #396611138 (Chromedriver 133 creates an extra window handle when opening a pdf in a new tab) which took at first time to find it and then months (from 21.02.25 - 05.05.25) to get into the stable version of 136. Now the next version, 137, got the next big issue. I hope it won’t take months again.

It’s also sad that the reason mentioned in RFC survey for not using Chrome-for-Testing “The reason is that we want to be as certain as possible that we’re getting the same results as customers would get” did not get more attention and that the flag was thrown away without any prior deprecation notice or error/warning message. What a luck that we tested it before the productional update and found it by chance.)

@hadastoroP neither of those currently work. You will have to stay on Chrome 136 or else switch to Chromium or Chrome-for-Testing.

I’m not sure why packed extensions would be affected.

I took a quick look at how this works in Selenium. If I’m understanding correctly, Selenium was passing --load-extension with the path to a CRX. That was actually just extracting the CRX file (CRX is a ZIP file with additional header data) and then loading the extracted folder as an unpacked extension.

@vinaghost you can still use --load-extension on non-Chrome branded builds like Chromium and Chrome for Testing. Thread - https://groups.google.com/a/chromium.org/g/chromium-extensions/c/aEHdhDZ-V0E/m/UWP4-k32AgAJ