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);