问题
I am using C#, Microsoft.VisualStudio.TestTools.UnitTesting and Selenium to test a website.
I know MS Edge is no longer being developed, and is being replaced with a Chromium-based product. In the interim, I would still like to be able to tell my customers that Edge is a supported browser until the replacement occurs.
But it looks like using the selenium EdgeDriver requires a valid microsoftwebdriver - and the latest one is not compatible with the latest version of Windows - my machine uses Windows 10 Version 1809 / build 17763.379.
Has anyone been able to get Edge testing to work with Selenium on a Windows 10 build 1809 machine? If so, please show some sample code and needed steps / references / usings / etc.
If seen a few posting about this where some responses say it is impossible, and others say it is possible - but the ones that say it is possible don't show any actual code or reference names.
回答1:
Sample C# Code
else if (AppSettings.Browser == "Edge")
{
EdgeOptions edgeOptions = new EdgeOptions()
{
UseInPrivateBrowsing = true,
};
driver = new EdgeDriver(edgeOptions);
}
and Remove all Nuget references to MicrosoftDriver, Clean the Solution Then Run the below command in CMD Admin mode
DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
Note: This Solution is for Microsoft Edge version 18 or Above
来源:https://stackoverflow.com/questions/55249358/c-sharp-selenium-testing-with-ms-edge-driver