I want to load an extension in Edge while using Selenium in C#.
I have figured I have to use EdgeOptions.AddExtensionPath()
but when passing the path no extensions are loaded.
The extension was extracted from %localappdata%\Microsoft\Edge\User Data\Default\Extensions
Here is the part of the code used to initialize the EdgeDriver:
using OpenQA.Selenium.Edge;
public void InitializeNewDriver() {
string microsoftWebDriverPath = @"some\path";
EdgeDriverService service = EdgeDriverService.CreateDefaultService(microsoftWebDriverPath);
EdgeOptions options = new EdgeOptions();
options.AddExtensionPath(@"path\to\extension\folder");
Driver = new EdgeDriver(service, options);
}
Edit: I'm using Selenium.Webdriver v4.0.0
I try to test the issue and found that if you pass the location of the extension to the
options.AddExtensionPath()
then the extension is not getting a load.I suggest trying to use the
options.AddExtensions()
method and pass the.CRX
file of the extension as a parameter.It can help you to load the extension successfully.
C# code example:
Output:
Further, you can modify the code sample as per your own requirements.