2

After upgrading to chromedriver 74 noticed odd extensions behaviour on Windows. Is it possible to switch ALL extensions off?

  1. Start chromedriver
chromedriver --log-level=ALL
  1. Create session with extensions DISABLED
curl -d '{"desiredCapabilities":{"browserName":"chrome","goog:chromeOptions":{"args":["--disable-extensions"]}}}' http://localhost:9515/session

Some dev tool extension is loaded

[1558606783.990][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-extensions-except="C:\Users\user\AppData\Local\Temp\scoped_dir19964_411\internal" --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --log-level=0 --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\user\AppData\Local\Temp\scoped_dir19964_22650" data:,

Note

--disable-extensions-except="C:\Users\user\AppData\Local\Temp\scoped_dir19964_411\internal"

Is there a way to get rid of it? Did not find any clues in chromedriver docs, those are extremely sketchy.

harshtuna
  • 757
  • 5
  • 14
  • 1
    There's a way to fool chromedriver - pass some other param along with --disable-extensions (separated by space), e.g. simply repeat it "--disable-extensions --disable-extensions". It works, but bit ugly. – harshtuna May 23 '19 at 10:36
  • Turns out it is not something new - found the same issue in chromedriver 2.36 – harshtuna May 23 '19 at 10:43
  • https://stackoverflow.com/questions/54594305/could-not-load-extension-from-scoped-dir6312-32763-internal-loading-of-unpacked – harshtuna May 24 '19 at 12:19
  • https://stackoverflow.com/questions/43571119/loading-of-unpacked-extensions-is-disabled-by-the-administrator – harshtuna May 24 '19 at 12:20
  • since Chromedriver v2.28 - https://bugs.chromium.org/p/chromedriver/issues/detail?id=1749#c5 – harshtuna May 24 '19 at 12:22

1 Answers1

1

TL;DR

Set chromeOptions.useAutomationExtension to false, it will prevent injecting of Chrome Automation Extension

{
  "desiredCapabilities": {
    "browserName": "chrome",
    "goog:chromeOptions": {
      "useAutomationExtension": false,
      "args": [
        "--disable-extensions"
      ]
    }
  }
}

Long version

Automation Extension flag is not mentioned in chromedriver docs http://chromedriver.chromium.org/capabilities, but can be traced in source code for current version (75.0.)

    parser_map["useAutomationExtension"] =
        base::Bind(&ParseBoolean, &capabilities->use_automation_extension);
    status = internal::ProcessExtensions(
        capabilities.extensions, extension_dir->GetPath(),
        capabilities.use_automation_extension, &switches, extension_bg_pages);
  if (include_automation_extension) {
    ...
    if (switches->HasSwitch("disable-extensions")) {
      UpdateExtensionSwitch(switches, "disable-extensions-except",
                            automation_extension.value());

As mentioned in 54594305 Java code using selenium driver would be

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
harshtuna
  • 757
  • 5
  • 14