简体   繁体   中英

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 ?

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");

更新到最新的兼容chromedriver.exe将解决该问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM