Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

java - Error Loading Extension Could not load extension from 'C:..LocalTempscoped_dir6312_32763internal'. Loading of unpacked extensions is disabled

When am running my webdriver script, am getting a confirmation dialog box with below message:

Error Loading Extension

Could not load extension from 'C:UsersusernameAppDataLocalTempscoped_dir6312_32763internal'. Loading of unpacked extensions is disabled by the administrator.

Would you like to retry?

Yes No

Clicking "yes" lets the tests run.

I am not sure why am I getting this dialog box prompted,

I've tried the mentioned workarounds below but neither of them are working:

  1. Replaced chrome driver with latest version.
  2. Added below code in my script:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("no-sandbox");
    options.addArguments("disable-extensions");
    driver = new ChromeDriver(options);
    

Below is my Test method:

public void Login() throws IOException{
    test = extent.startTest("Login");
    signInPage = new SignInPage(driver);
    signInPage.enterMailId();   
    String screenShotPath = GetScreenShot.capture(driver, "enterMailId");
    test.log(LogStatus.PASS, "Email id is entered successfully: " + test.addScreenCapture(screenShotPath));
    signInPage.enterpwd();
    //test.log(LogStatus.INFO, "Password is entered successfully");
    screenShotPath = GetScreenShot.capture(driver, "enterpwd");
    test.log(LogStatus.PASS, "Password is entered successfully: " + test.addScreenCapture(screenShotPath));
    signInPage.clickOnLogin();
    test.log(LogStatus.PASS, "User logged in successfully");
}

Below is the method which invoke the browser:

private  void initChromeBrowser(){
    System.setProperty("webdriver.chrome.driver", userdir +"\chromedriver.exe");
    ChromeOptions options = new ChromeOptions();
    options.addArguments("test-type");
    options.addArguments("no-sandbox");
    //Fix for cannot get automation extension
    options.addArguments("disable-extensions");
    options.addArguments("start-maximized");
    options.addArguments("--js-flags=--expose-gc");         
    options.addArguments("disable-plugins");
    options.addArguments("--enable-precise-memory-info"); 
    options.addArguments("--disable-popup-blocking");
    options.addArguments("--disable-default-apps");
    options.addArguments("test-type=browser");
    options.addArguments("disable-infobars");
    driver = new ChromeDriver(options);
    launchApp();
}

Could there be anything else that I should incorporate in my script to prevent the dialog box.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can set the useAutomationExtension capability to false.

    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("useAutomationExtension", false);
    WebDriver driver = new ChromeDriver(options);

This capability will help to not load Chrome Automation extension. Due to which, "Failed to load extension" popup would not appear.

But please note you will not be able to perform any window resizing/positioning operations without the Chrome automation extension.

Hope this helps!

Source : https://bugs.chromium.org/p/chromedriver/issues/detail?id=1749


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...