WebDriver 16299 cannot load Edge extension.

Not reproducible Issue #15598729

Details

Author
Tian L.
Created
Jan 24, 2018
Privacy
This issue is public.
Found in
  • Microsoft Edge
Reports
Reported by 6 people

Sign in to watch or report this issue.

Steps to reproduce

Browser Version:
Microsoft EdgeHTML 16.16299 (64-bit)

Expected Behavior -

Edge installed extersion can be loaded while Edge broswer initializing.

Actual Behavior -

Edge installed extersion CANNOT be loaded while Edge broswer initializing.

Steps to reproduce -

Env:
OS:
Windows 10 Enterprise 1709 (OS build 16299.192)
Selenium Version:
2.51.0, 3.8.1

  1. Installed Extension:
    ms-browser-extension://EdgeExtension_AdguardAdguardAdBlocker_m055xr0c82818/

  2. Use Java API to trigger webdriver

Attachments

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Steven K.”

  • Hi Tian,

    I want to make sure I understand the issue.  Edge works as expected during normal browsing with the Adguard AdBlocker Extension enabled, however, webDriver testing does not work with it enabled?

    Do you have the desktop application installed as well?

    Steve

  • Hi Steve,

    Thanks for looking into this issue.

    Yes. Edge works as expected during normal browsing with the Extension(Eg. Adguard AdBlocker) installed. And I can see the extension’s icon shows next to Edge’s address bar. This means the extension is loaded with Edge started.

    But while I;m launching Edge via webDriver(Selenium Java code). The extensions tab is empty. So the extensions were not be loaded.

    I got this issue when Windows 10 OS was updated to 1709 (Edge: 16.16299).
    For Windows 10 1703 - with MicrosoftWebDriver_15063.exe, the extensions could be loaded with Selenium automation.

    quote:

    • Do you have the desktop application installed as well?
      => Excuses, I don’t know what’s the mean of "the desktop application". Edge installed app?

    ===
    BTW, I tried webDriver C# API this morning. There is an API “edgeOptions.AddAdditionalCapability” which Java code(Edge) doesn’t have this.

    Does this option have a chance to give a workground to load Edge extension via webDriver?
    eg.
    EdgeOptions edgeOptions = new EdgeOptions();
    edgeOptions.AddAdditionalCapability(“extensionPaths", @"C:\Users\tliu\AppData\Local\Packages\Adguard.AdguardAdBlocker_m055xr0c82818”);

    Please advise, thanks.

    • Tim
  • Thank you for the response.  Apparently, AdGuard Adblocker has an option for additional capabilities if the desktop application is also installed.  I believe if the desktop application is installed the extension’s behavior is modified.  I just wanted to verify the test environment I should create.  It sounds like you are only using the extension.

    The C# class:class
    EdgeOptions
    : DriverOptions

    does not have the option to load or not load user extensions. This parameter/option allows for future configuration options, logging capabilities, and some other items.

    https://seleniumhq.github.io/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Edge_EdgeOptions.htm

    Edge supports only one user profile.  Because of this the extensions and setting that you have in the user account you are testing in will be used.  This includes the extensions and settings.

    I will run some testing to reproduce what you are seeing and then see about what can be done to correct the issue.

    Steve

  • Great! Thanks for your help. Please ping me if the original issue couldn’t be reproduced in your environment.

    -Tim

  • Yes, I will post any questions I have.

    I was just thinking about this ticket again and remembered that I noticed some new delays in the newer Selenium webDriver bindings and/or the MicrosoftWebDriver.exe.  I am guessing this could be the issue.  I.e. that Edge has is not fully loaded before the Java test code’s timeout fires.  Can you try adding a delay?  I would try an implicit wait first.  Also, not that implicit and explicit waits should not be used in the same test case/instance of the driver.

    https://stackoverflow.com/questions/10404160/when-to-use-explicit-wait-vs-implicit-wait-in-selenium-webdriver

    I recommend the implicit wait first because you add this wait in one place right after created the driver object and before running any tests.

    The best longer term solution is to use explicit waits where needed.

    https://stackoverflow.com/questions/31221778/selenium-webdriverwait-timeout

    I will test the same, however, I wanted to send a note to let you know now about this possible cause and workaround.

    Steve

  • I think Edge load extension action did happen at Edge webDriver object initialized. But the implicit/explicit wait can be used only after browser launched.

    I recorded my testing.
    https://1drv.ms/v/s!AoYmgWoCQXIQh1CsR380vdkCJTrC
    Simple code:

    1.  static private RemoteWebDriver _driver;
       static void Main(string[] args)
       {
           // Create new Edge Driver
           _driver = new EdgeDriver();
       }
      
    2.  static private RemoteWebDriver _driver;
      
       static void Main(string[] args)
       {
           // Create new Edge Driver
           _driver = new EdgeDriver();
           System.Threading.Thread.Sleep(10000);
           _driver.Manage().Window.Maximize();
           _driver.Url = "https://www.bing.com";
           Console.ReadKey();
       }
  • Hi,Tian
    Are you able to load extension in EDGE through JAVA code before your Windows upgrade? For loading extension through code I mean like
    EdgeOptions option = new EdgeOption();
    option.setCapability("extensionPaths", “path to extension”);
    WebDriver driver = new EdgeDriver(option);

      Not pre-install extension in Edge than use code to open the browser.
  • Hi Tian,

    I wanted to let you know that I am still investigating this.  I am checking to see if my original statement about the extensions being loaded by default is accurate.  In my testing so far, this has not been the case.  I am verifying if this is expected behavior from one of our developers.

    @anonymous, do you have a working example of using EdgeOptions to load an extension programmatically?

    Steve

  • Hi Steve,

    For the Edge version on Windows 10 1703, if an extension was installed.
    The extension can be loaded with Edge start up.

    Just one line simple code after selenium WebDriver import.

    import org.openqa.selenium.*;
    import org.openqa.selenium.chrome.*;
    import org.openqa.selenium.edge.EdgeDriver;
    import org.openqa.selenium.edge.EdgeOptions; 
    
        if(browserType.equalsIgnoreCase("Edge")) {
            driver=new EdgeDriver();
        }
    

    I don’t know what the extra api to program EdgeOption

    But as for Chrome browser, add a argument to ChromeOptions could work.

        if (browserType.equalsIgnoreCase("Chrome")){
            ChromeOptions options=new ChromeOptions();
            options.addArguments("-load-extension=" + pathToExtension);
        }
    
  • Hi Steve, unfortunately,
    I was not able to do that using above JAVA code. Though I follow the instruction provided on Edge’s wiki https://docs.microsoft.com/en-us/microsoft-edge/extensions/guides/packaging/creating-and-testing-extension-packages#automated-testing-with-webdriver , and I follow the C# example, but somehow it just doesn’t work.

  • But according to Scott https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9303555/ , this feature is still in backlog, so I’m a bit confusing.

  • Hi Tian,

    I think we can clear up part of the confusion.  It appears that the default behavior for loading extensions has changed.  This is based on the link you sent stating that changes were made as of the Anniversary Update.  My testing has shown this as well.  I.e. I did not see any extensions being loaded by default.  So the ticket you sent me about this had an issue that the submitter did not like.  I.e. a pop-up that required human intervention asking whether extensions should be loaded.  This pop-up is now gone as well as extensions loading automatically.

    Your link is helpful and I will test this in C# and then try in Java.  I think the key is to create an array of extension paths to load.  I will test if this will also work for extensions installed from the Microsoft App Store and if the extensions need to be copied or sym linked to the “LocalState” subdirectory of Edge.

    I will also verify the workaround that Scott mentioned about performing an Xcopy of the extension if it is from the Microsoft App Store.  I think Scott’s statement meant that at that time there was no support for setting the extension information programmatically via the EdgeOptions Object.

    I will track down the details and the current status.

  • Hi Steve,

    It’s awesome if we can load an online version extension from the Microsoft App Store.

    For me, I’m going to test an extension. Then it’s good enough that I can load a local unpacked extension build via webDriver.

    Great job!

    -Tim

  • Hi Steve,

     Thank you for clarifying! What I wanna do is the same as what Tian want, load an extension through Webdriver at runtime, could be either packed appx or unpacked. Could you confrim with Scott what kind of extension we can load through Wendriver? I've try packed appx, unpacked extension w/ AppXManifest.xml, unpacked extension w/o AppXManifest.xml and none of them works. So it would be great if it's clarified.
    

    Thanks,
    Marvin,

  • One of our developers explained the new process for loading extensions from the App Store and your own extensions for use in WebDriver testing.

    The procedure is basically what was outlined in the link provided in this thread previously:

    https://docs.microsoft.com/en-us/microsoft-edge/extensions/guides/packaging/creating-and-testing-extension-packages#automated-testing-with-webdriver

    Except now we have the details on how to get a copy of any of your installed extensions.

    Here is an outline of the procedure:

    • Create a new directory in the following location:
      C:\users<username>\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\LocalState\
    • Go to the c:\program files\windowsapps directory and find the extension you want to have loaded.

    Example: @"c:\Program Files\WindowsApps\Adguard.AdguardAdBlocker_2.8.4.0_neutral__m055xr0c82818"

     Note: due to permissions, you will likely need an admin cmd prompt.

    • Inside that directory will be a folder containing the manifest.json file.  It is named ‘Extension’ in the case of AdguardAdBlocker.
    • Copy all of the contents of the Extension folder into the directory created above.  The attached Scott Low based example code is using "Extensions".
    • Then add the following code to your project where the extensionPaths variable is of type string[];

    options.AddAdditionalCapability("extensionPaths", extensionPaths);

    I have modified Scott Low’s code at the following link for the specific use case in this bug report (AdguardAdBlocker) and have attached it here.  Scott’s added functionality automates copying the extension you specify for var extensionPath.  Search for the and modify as needed.  Currently set to AdguardAdBlocker.

    To run the testing, open the solution .sln file in Visual Studio.  Then click on the method gotoSeleniumWikiPage() and then right click and select ‘Run Tests.’

    Let me know if you would like the same thing in Java as I have only tested this in C#.

    Steve

  • Hi Steve,

    Thanks for your testing. The C# code works from my side. Now I realized my script’s issue - the extension must be loaded from "Microsoft.MicrosoftEdge_8wekyb3d8bbwe\LocalState". Seems I didn’t copy it to the required directory.

    I do need the same thing in Java, there is a method called setCapability(). But I don’t know the argc detail. It doesn’t work with -

    setCapability("extensionPaths", String[]);
    

    Please advise :)

    -Tim

  • Hi Steve,

    You said after Anniversary Update. A pop-up that required human intervention asking whether extensions should be loaded is now gone as well as extensions loading automatically. But when I was test in JAVA, it still pop up a bar and asked me to turn on the extension manually. My Edge version is 40.15063.674.0, I think it should be a very new version, but still don’t have that feature. Can you try on your side? Thanks!
    -Marvin

  • @Anonymous, the original pop-up was different than what is there now.  The pop-up now will ask if you are sure you want to enable extensions.  I believe this happens only the first time?  Will you provide the extended version of Windows 10 you are using?  Win + S and type “winver” and hit enter.  The Edge version isn’t always enough information.

    @Tian, I will see about finding the option information for Java.

    Steve

  • Tian,

    I believe what you have should be correct for the Java version.  My testing so far was not able to get an extension to load as well.  Let me do more investigation for the Java bindings.  As an FYI, here is what I tried.  The extension was already copied over before running this test.  E.g. by running the C# version.

    private String localAppDataDir = System.getenv(“LOCALAPPDATA”);
    private String edgeSideLoadPath = localAppDataDir + "\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\LocalState\Extensions\";
    private String extensionPath = localAppDataDir + "\Packages\Adguard.AdguardAdBlocker_m055xr0c82818";

    @BeforeClass
    public void setUp() {

    EdgeOptions options = new EdgeOptions();

    options.setPageLoadStrategy(“normal”);

    String[] extensionPaths = new String[] { extensionPath };

    options.setCapability("extensionPaths", extensionPaths);

    driver = new EdgeDriver(options);
    }

  • Yes.
    Thanks Steve.

    I have no idea about the Java bindings coz I didn’t find any thing about keyword “extensionPaths” from source code.
    Look forward to your investigation.

    -Tim

  • Hi Tian,

    I thought I would give you an update.  I was not able to get the same thing to work with the Java bindings.  I will send this on to one of the developers that was helping us with this.

    Steve

  • Hello all,
    according to all the comments above, is there something update of the java bindings? Will some fix of the current webdriver for Edge HTML16.16299 happens to support existed edge extension be loaded like the webdriver for Edge HTML15?
    Thanks!

  • Microsoft Edge Team

    Changed Assigned To to “edgedevtoolstri”

  • I was able to get the Java version working.  It was a coding mistake on my part.  One of our developers here showed me how to enable verbose logging.  I re-wrote the repro as a Java console app so that the console is visible.

    Below are the steps to sideload an extension in Edge using the Java bindings.

    Assumptions:
    // My repro requires the extension files to be manually copied to the sideload directory.  I put a reminder of those steps at the end of this post.
    // requires java >=1.8, maven 3.x
    // java -version
    // mvn -v

    • unzip webdriverjavaextensionsapp.zip
    • edit App.java to update paths for your Users<username> && the extension you want to run
      vi C:\code\webdriverjavaextensionsapp\src\main\java\com\microsoft\webdriverjavaextensions

    private String edgeSideLoadPath = "C:\Users\…

    private String extensionPath 

    • open admin powershell (in case you add the same xcopy similar to the C# version previously provided in this ticket.
    • change to the directory containing the pom.xml file
      cd C:\code\webdriverjavaextensionsapp
    • BUILD
      mvn clean compile package
    • run
      java -jar target/AppFatJar-1.0-SNAPSHOT-spring-boot.jar

    Notes on sideload paths:

    • Create a new directory in the following location:
      C:\users<username>\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\LocalState\
    • Go to the c:\program files\windowsapps directory and find the extension you want to have loaded.
      Example: @"c:\Program Files\WindowsApps\Adguard.AdguardAdBlocker_2.8.4.0_neutral__m055xr0c82818"

     Note: due to permissions, you will likely need an admin cmd prompt.

    • Inside that directory will be a folder containing the manifest.json file.  It is named ‘Extension’ in the case of AdguardAdBlocker.
    • Copy all of the contents of the Extension folder into the directory created above.  The attached Scott Low based example code is using "Extensions".
  • Microsoft Edge Team

    Changed Status to “Not reproducible”

  • Looks Steven was able to get this working. 

  • Hello Steven,

    Great Job. I’m going to have a try on my side. Could you please attach the “webdriverjavaextensionsapp.zip” file?

    Thanks,
    Tim

  • oh my!  I forgot to prepend the file with 'public-'! :-(

    I corrected that, and you should now see the attachment.  Thank you for letting me know.  I rode away like Don Quixote feeling good about myself; leaving a mess.  :-/

  • I am also extracting the main Java code for setting the extension side load path here so you do not have to download and extract the App.java file to see the basic usage.  Be careful on copy and paste due to the various special character conversion issues, E.g. '"’.

    private String edgeSideLoadPath = "C:\Users\<your_username>\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\LocalState\Extensions";
    public void setUp() {
        System.setProperty(EdgeDriverService.EDGE_DRIVER_VERBOSE_LOG_PROPERTY, “true”);
        service = EdgeDriverService.createDefaultService();
        options = new EdgeOptions();
           String[] extensionPaths = new String[] { edgeSideLoadPath };
           options.setCapability("extensionPaths", extensionPaths);
           driver = new EdgeDriver(service, options);
    }

  • Hi Steven,

    Your code works well with Selenium 3.11.0. Thanks for your excellent work. Really appreciate it. Have a good day.

    Best wishes,
    Tim

  • Thanks all for the fixes. Everything works great now.

  • Right now the webdriver cannot be used with the built-in administrator account, right?

  • I am not aware of that limitation.  Is this on a Windows Server?  I am running in my local/domain account that has admin privileges from an admin PowerShell.

    Are you referring to the xcopy command to automate the extension files being copied to the proper local user directory?  I know that requires admin rights and I was not able to get that to work in IntelliJ running with testNG.  That was how I normally create test cases and then just run the tests I need.  I believe the issue there is that IntelliJ does not have the permissions to access the extension source directory.  The xcopy command does work in Visual Studio.

  • I just tested running the MicrosoftWebDriver.exe as admin by right clicking the exe and selecting 'Run as Administrator’.

  • In fact I’m using a domain administrator user who has the highest privilege, this is not about the admin rights. Using this user, webdriver 16299 and running windows command like: java -cp “…selenium 3.11 dependencies” test, there will be an error that "webdriver cannot be used with the built-in administrator account".
    With Edge HTML version 15, if user such as this kind of built-in administrator, launching Edge will give this error "this app cannot be launched by built-in administrator"; While with Edge HTML version 16, the bulit-in administrator won’t have this kind of limitation.
    With common user in admin group won’t have this kind of error message.

  • Hi Steven,

    During using the method I hit another problem. For the edge extension installation package installs both extension and some other dependencies binaries, only copying the extension folder to “C:\Users\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\LocalState\Extensions” can only load the extension, but missing the binaries will cause extension work abnormally. What should I handle this situation? Thanks!

  • Hi Jessica,

    Related to your previous comment about the Domain Administrator issue.  You are logging in to a Windows 10 machine using this account correct?  I.e. you are not running on a Windows Server?  Also, will you provide the extended version of Windows 10 you are using?  Win + S and type “winver” and hit enter.  I will ask about this issue.  I have not tried using this type of account.  Did you create another user account as a work around?

    Related to your extension requiring additional binaries, I believe this could be an issue because of the new Application Security model that Edge runs in.  I will ask about this to be sure.  I think this feedback is useful as well.  As an example, I saw that AdGuard AdBlocke
    r could also run with an installed binary.  In this scenario the AdGuard AdBlocker extension behaves different.

  • Hi Steven,

    Thanks for your reply.
    Yes, I am logging into a windows 10 machine using the domain administrator, The windows 10 version is 1709 build 16299.371. Changing to another account which is not built-in administrator can be a work around. I’m not running on a windows server.

    For the additional binaries problem, looking forward to your information. Thanks!

  • Hi Jessica,

    I have been talking some of our developers and we need additional information on the binary installation.  Where are the binary files installed?  Does the binary installation modify registry settings and/or other system environment variables?

    Can you provide an example or your extension that I can test with?  If you want you can send it to my e-mail for privacy.

    Steve

  • Hi Steve,

    Thanks for your reply. I check with the binary installation, the location is under "C:\program files\windowsapps". I have tried to copied all files under this folder to “C:\Users\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\LocalState", but no use.
    Since the extension I use is not published, I will notify you when it is available in Microsoft Store. Thanks.

  • Hi Jessica,

    Thank you for the response.

    The reason I was asking is that there might be a way to automate the full installation of the extension during a webDriver test execution run.  I wanted to test the procedure before sending the information out.  I am also waiting for information on that possibility as well, so I do not have any new information yet.  I was trying to get information from you and my internal team at the same time.  :)

    Steve

  • Hi Steven,

    Finally our extension is live in Microsoft store. Could you please provide an email address then I can pass you the extension name. Thanks!

  • Hi Jessica, that is great news.  I will send you an e-mail now with my contact info.

    Steve

  • Hello!

    With this we can activate extensions with JavaScript only.
    Is it possible to use Edge extensions using native messaging?
    Is it possible to define the location of the UWP App to which the extension wants to connect to?

    browser.runtime.lastError.message says “Native Messaging not supported for non-packaged extensions” when the extension is trying to establish a connection via browser.runtime.connectNative.

    The extension works when Edge is manually started (not via WebDriver) and the UWP App (containing the JS-part of the edge extension) is installed.

    Please also have a look at https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15049098/

    Regards,
    Dominik

You need to sign in to your Microsoft account to add a comment.

Sign in