WebDriver 16299 cannot load Edge extension.

Issue #15598729 • Assigned to Steven K.

Details

Author
Tian L.
Created
Jan 24, 2018
Privacy
This issue is public.
Found in
  • Microsoft Edge
Reports
Reported by 3 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

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

Sign in