What is the selenium version you're using? If you're using Selenium 4.00-alpha03 and earlier, you could refer to the following steps to automate Microsoft Edge Chromium:
- Install the C# Selenium WebDriver 3.141.0 from here.
- Download the matching version of Microsoft Edge Driver from this page.
- Example C# code:
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Remote;
using System.Collections.Generic;
using System.Threading;
var service = EdgeDriverService.CreateDefaultService(@"C:\Selenium\Drivers", @"msedgedriver.exe");
service.UseVerboseLogging = true;
service.UseSpecCompliantProtocol = true;
service.Start();
var caps = new DesiredCapabilities(new Dictionary<string, object>()
{
{ "ms:edgeOptions", new Dictionary<string, object>() {
{ "binary", @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" }
}}
});
var driver = new RemoteWebDriver(service.ServiceUrl, caps);
driver.Navigate().GoToUrl("https://bing.com");
Thread.Sleep(2000);
driver.Close();
service.Dispose();
Note: Change the paths in the code to your owns.
-----------------------------------------------------------------Update-----------------------------------------------------------
You need to use Selenium 4.00-alpha04 to use the browser-specific options classes when automating Edge Chromium:
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Remote;
EdgeOptions edgeOptions = new EdgeOptions(false);
edgeOptions.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
var msedgedriverDir = @"C:\Selenium\Drivers";
var msedgedriverExe = @"msedgedriver.exe";
var service = EdgeDriverService.CreateDefaultService(msedgedriverDir, msedgedriverExe, false);
service.EnableVerboseLogging = true;
var driver = new EdgeDriver(service, edgeOptions);
driver.Navigate().GoToUrl("https://bing.com");
Thread.Sleep(2000);
driver.Close();
Note: Change the paths in the code to your owns.