使用 MS Edge 驱动程序进行 C# Selenium 测试 [英] C# Selenium testing with MS Edge driver
问题描述
我正在使用 C#、Microsoft.VisualStudio.TestTools.UnitTesting 和 Selenium 来测试网站.
I am using C#, Microsoft.VisualStudio.TestTools.UnitTesting and Selenium to test a website.
我知道 MS Edge 不再被开发,而是被基于 Chromium 的产品所取代.在此期间,我仍然希望能够告诉我的客户 Edge 是受支持的浏览器,直到更换发生为止.
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.
但看起来使用 selenium EdgeDriver 需要一个有效的 microsoftwebdriver - 而最新的与最新版本的 Windows 不兼容 - 我的机器使用 Windows 10 Version 1809/build 17763.379.
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.
有没有人能够在 Windows 10 build 1809 机器上进行 Edge 测试以与 Selenium 一起使用?如果是这样,请显示一些示例代码和所需的步骤/参考/使用/等.
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.
推荐答案
示例 C# 代码
else if (AppSettings.Browser == "Edge")
{
EdgeOptions edgeOptions = new EdgeOptions()
{
UseInPrivateBrowsing = true,
};
driver = new EdgeDriver(edgeOptions);
}
并删除对 MicrosoftDriver 的所有 Nuget 引用,清理解决方案然后在 CMD Admin 模式下运行以下命令
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
注意:此解决方案适用于 Microsoft Edge 18 或更高版本
Note: This Solution is for Microsoft Edge version 18 or Above
这篇关于使用 MS Edge 驱动程序进行 C# Selenium 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!