Sep 22 2020 08:38 AM
I want to add chrome extension from Selenium Java to Newest Edge Version with msedgedriver.
But when the browser instance opens the extension is not getting added and developer mode is not
i. Edge Developer mode gets turned off when new instance is opened.
ii. Allow extensions from other stores is also automatically turned off.
I tried different codes with seleenium 4.0 alpha 6.0 as well as with the stable versions.
public static WebDriver ini() {
System.setProperty("webdriver.edge.driver", "D:\\SeleniumTest\\new\\msedgedriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities ();
EdgeOptions options = new EdgeOptions();
ArrayList<String> extensionList=new ArrayList<String>();
String extensionLocation="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\85.0.564.51\\Extensions\\CombinedExtension";
extensionList.add(extensionLocation);
options.setCapability( "disable-infobars", true);
options.setCapability("extensionPaths", extensionList);
options.merge(desiredCapabilities);
WebDriver driver = new EdgeDriver(options);
return driver;
}
The above code works fine with edge legacy.
Also different other answers i have tried most of them doesnt work.
I tried the below code too
System.setProperty("webdriver.edge.driver", "<windowsMsEdgeChromiumDriverPath>"); final ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe"); chromeOptions.setExperimentalOption("useAutomationExtension", false); chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation")); final EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions); final WebDriver webDriver = new EdgeDriver(edgeOptions);
Sep 22 2020 11:38 AM
@farisk2010 Thanks for letting us know, and welcome to the MSFT Edge Insider community!
I believe @johnjansen has done related webdriver work and might be able to help.
Fawkes (they/them)
Program Manager & Community Manager - Microsoft Edge
Sep 22 2020 01:32 PM
Solutionthanks for tagging me, @Deleted .
@farisk2010 , I think you just have they syntax incorrect for enabling extensions via the current driver design:
var options = new EdgeOptions();
options.AddArguments("load-extension=/path/to/extension");
so something like this:
public static WebDriver ini() {
System.setProperty("webdriver.edge.driver", "D:\\SeleniumTest\\new\\msedgedriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities ();
EdgeOptions options = new EdgeOptions();
//ArrayList<String> extensionList=new ArrayList<String>();
String extensionLocation="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\85.0.564.51\\Extensions\\CombinedExtension";
//extensionList.add(extensionLocation);
options.setCapability( "disable-infobars", true);
options.setCapability("extensionPaths", extensionList);
options.AddArguments("load-extension=" + extensionLocation);
options.merge(desiredCapabilities);
WebDriver driver = new EdgeDriver(options);
return driver;
}
Sep 22 2020 11:56 PM
@johnjansen and @fawkes
Thank you for your reply. It worked fine and the extension is getting added
Sep 23 2020 10:25 AM
@farisk2010 Excellent, we're glad to hear it! Best of luck with the extension.
Fawkes (they/them)
Program Manager & Community Manager - Microsoft Edge
Sep 22 2020 01:32 PM
Solutionthanks for tagging me, @Deleted .
@farisk2010 , I think you just have they syntax incorrect for enabling extensions via the current driver design:
var options = new EdgeOptions();
options.AddArguments("load-extension=/path/to/extension");
so something like this:
public static WebDriver ini() {
System.setProperty("webdriver.edge.driver", "D:\\SeleniumTest\\new\\msedgedriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities ();
EdgeOptions options = new EdgeOptions();
//ArrayList<String> extensionList=new ArrayList<String>();
String extensionLocation="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\85.0.564.51\\Extensions\\CombinedExtension";
//extensionList.add(extensionLocation);
options.setCapability( "disable-infobars", true);
options.setCapability("extensionPaths", extensionList);
options.AddArguments("load-extension=" + extensionLocation);
options.merge(desiredCapabilities);
WebDriver driver = new EdgeDriver(options);
return driver;
}