C# Selenium testing with MS Edge driver

蹲街弑〆低调 提交于 2020-12-31 15:05:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!