Unable to open chrome browser using Selenium Webdriver. Loading unpacked extensions are disabled by administrator

前端 未结 7 1497
名媛妹妹
名媛妹妹 2021-01-01 05:50

I am automating my application using Selenium Webdriver, C#, Visual Studio and Chrome browser.

I am getting below popup when selenium tried to open the chrome browse

相关标签:
7条回答
  • 2021-01-01 05:59

    Help overcome how, exactly?

    Selenium requires a helper extension to function. An enterprise policy lockdown is in effect, so you can't add it.

    You will need to raise the problem with your IT dept if you want to run tests, after all you have a valid reason.

    Update: It seems that Selenium can now run without the automation extension. See, for example, this answer for details on how to start Chrome without the extension if you must avoid its use.


    Chromedriver seems to always put its unpacked extension into a random temp location, which causes a random ID. This makes it impossible to whitelist the extension.

    In fact, no, the ID of the extension is pinned. However, the enterprise policy does not allow whitelisting of unpacked extensions. Which is reasonable, as it would allow to bypass the security (all you need is the key fields in the manifest to impersonate the ID).

    Making Chromedriver load packed extensions seems to require a lot of reworking, and considering the Windows limitations on installing them may be downright impossible.

    Corresponding Chromedriver bug (very much ignored, it seems).

    0 讨论(0)
  • 2021-01-01 06:03

    The unpacked extension error popped up for me and I requested for removing the restrictions in chrome which was enforced as organizational policy. Once the restrictions were removed, I am able to run the program with out any errors. ChromeBrowser-GPO-Deny - this was the one which was removed. You can check in Settings - Extensions - Check on Developer mode and see if the load unpacked extensions is checked once the restrictions are removed. You should be good then.

    0 讨论(0)
  • 2021-01-01 06:09

    I tried using AddExtension and AddArgument methods of ChromeOptions class, but none of them worked and got the same error.

    I did something like this (JAVA):

    ChromeOptions o = new ChromeOptions();
    o.addArguments("disable-extensions");
    o.addArguments("--start-maximized");
    WebDriver driver = new ChromeDriver(o);
    

    The second line is all what you need. The third line is just making chrome window maximized.

    The pop-up isn't showing up currently. HTH.

    0 讨论(0)
  • 2021-01-01 06:13

    The part of the stack trace

      System.InvalidOperationException: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
    

    is because of 3rd party extensions installed on Chrome. Check if you have any extensions installed, like Add Blockers or something.

    I encountered the same problem and was able to solve them by deleting the extensions installed in Chrome. If you have any extensions installed in chrome I am pretty sure removing them should solve the issue.

    0 讨论(0)
  • 2021-01-01 06:18

    Hope this below solution will help you.

    1. Open Registry Editor
    2. Search for below keys HKEY_CURRENT_USER\Software\Policies\Google\Chrome\ExtensionInstallBlacklist HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallBlacklist
    3. If you find any keys set under above location, just delete it.
    0 讨论(0)
  • 2021-01-01 06:18

    This error message...

    Failed to load extension from:C:\Users\VARA~1.PAK\AppData\Local\Temp\scoped_dir6712_14913\internal.
    Loading of unpacked extensions is disabled by the administrator.
    
    ...implies that an extension was not been loaded as it was disabled by the administrator.
    

    As per the discussion Failed to load extention from: ... Loading of unpacked extensions is disabled by the administrator ChromeDriver uses Chrome automation extension for automating various functions like window sizing, window positioning, etc.

    The Failed to load extension popup means that this extension has not been loaded. If you manually close the popup, browser will act normally and ChromeDriver commands will continue to work as expected. But in this case if you try executing window resizing or window re-positioning commands, it will throw an error as unknown error: cannot get automation extension.

    Background: Till ChromeDriver v2.28 whenever an organizations admin policy forbidden extensions, to bypass the restriction users have used the argument disable-extensions as follows (Java Code Sample):

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

    and it worked perfecto.

    ChromeDriver v2.28 onwards, whenever disable-extensions flag is passed by test, ChromeDriver implicitly passes disable-extensions-except flag which in turn loads Chrome automation extension. This extension helps Chromedriver to perform window sizing and window re-positioning operations.

    So, if your organizational admin policy blocks extensions, display of popup Failed to load extension from: ... Loading of unpacked extensions is an expected behavior.

    Solution

    As a solution, you can set the useAutomationExtension capability to false as follows (Java Code Sample):

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

    This capability inturn will help to not load Chrome Automation extension and Failed to load extension popup would not appear. But you will not be able to perform any window resizing/positioning operations without the Chrome automation extension.

    trivia

    The best approach would be to use the latest version of ChromeDriver and Chrome combination among either of the following:

    • If you are using Chrome version 73, please download ChromeDriver 73.0.3683.20
    • If you are using Chrome version 72, please download ChromeDriver 2.46 or ChromeDriver 72.0.3626.69
    • If you are using Chrome version 71, please download ChromeDriver 2.46 or ChromeDriver 71.0.3578.137
    • For older version of Chrome, please see this discussion.

    Alternatives

    Some diverse alternatives:

    • Add the Registry Key ExtensionInstallWhitelist to whitelist
    • Remove the Registry Key ExtensionInstallBlacklist containing a string key 1 with value *
    0 讨论(0)
提交回复
热议问题