Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to load extension from popup box while running selenium scripts

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 ?

like image 368
kaushik3993 Avatar asked Dec 11 '22 11:12

kaushik3993


1 Answers

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");
like image 85
Markus Dietler Avatar answered Dec 13 '22 01:12

Markus Dietler