4

I get the following popup box when I try to run my selenium script in java:

Failed to load extension from:
C:\Users\xyz\AppData\Local\Temp\scoped_dir20432_5430\internal. Loading of unpacked extensions is disabled by the administrator.

I have tried chromeoption arguments I have found in other pages. But none seems to work.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testClass {

     public static String driverPath = "D:/Selenium/Chrome Driver latest/chromedriver.exe";
     public static WebDriver driver;

public static void main(String args[]) {
    System.setProperty("webdriver.chrome.driver", driverPath);

    ChromeOptions options = new ChromeOptions();
    options.addArguments("test-type");
    options.addArguments("start-maximized");
    options.addArguments("--js-flags=--expose-gc");
    options.addArguments("--enable-precise-memory-info");
    options.addArguments("--disable-popup-blocking");
    options.addArguments("--disable-default-apps");
    options.addArguments("--enable-automation");
    options.addArguments("test-type=browser");
    options.addArguments("disable-infobars");
    options.addArguments("disable-extensions");

    driver = new ChromeDriver(options);
    driver.navigate().to("http://google.com");
    driver.quit();
}
}

I am forced to handle that popup manually. How do I get rid of it ?

kaushik3993
  • 105
  • 1
  • 3
  • 10

2 Answers2

13

I had the same problem and I finally found a working answer in another thread. Loading of unpacked extensions is disabled by the administrator

The following line did the trickt for me

options.setExperimentalOption("useAutomationExtension", false);

There are some trade-offs mentioned in the link, like window resizing operations with the Chrome automation extension aren't possible anymore. Anyway, starting with the start-maximized argument still worked fine in my code.

options.addArguments("start-maximized");
Markus Dietler
  • 146
  • 2
  • 5
  • 1
    Thanks so much. I was looking for this for a very long time. – kaushik3993 Jul 05 '17 at 10:16
  • This answer works for NightwatchJS as well. In your `nightwatch.json` config file, do: `{"test_settings":{"default":{"desiredCapabilities":{"browserName":"chrome","goog:chromeOptions":{"useAutomationExtension":false}}}}}` – zwbetz Jul 14 '20 at 20:57
  • I tried everywhere and couldn't resolve it but you have given the correct statement to overcome this. thank you Markus sir – Anupam Haldkar Jul 30 '20 at 06:26
0

Updating to the latest compatible chromedriver.exe will resolve the issue.

zappee
  • 20,148
  • 14
  • 73
  • 129