有没有办法在 Edge Options 中激活 IE 模式?
Is there a way to activate IE mode in Edge Options?
您好,
我想通过在 EdgeDriver 中添加一个选项来实现这一点,但我似乎无法在地图上的任何地方找到它?
我正在尝试使用 Selenium 和 EdgeDriver 在 Edge 中以 IE 模式打开页面。
有没有办法实现这个伟大的事情? [双关]
我可以在这个帖子中看到 2 个问题。
- 有没有办法在 Edge 选项中激活 IE 模式?
无法绕过 Selenium Edge 驱动程序中的 Edge 选项参数来激活 IE 模式。
- 我正在尝试使用 Selenium 和 EdgeDriver 在 Edge 中以 IE 模式打开一个页面。有没有办法实现这个伟大的事情?
是的,可以使用 Selenium 网络驱动程序在新的 MS Edge 浏览器中自动执行 IE 模式。
新的 Microsoft Edge 允许您 运行 除了现代体验之外,还可以对旧网站进行 IE11 验证。要在 Microsoft Edge 中 运行 进行 IE11 测试,请从 Selenium 下载 IEDriverServer。然后您必须传递将 Microsoft Edge 置于 IE 模式的功能,然后 运行 您的测试。
因为此功能会将整个浏览器置于 IE11 模式,您无法同时测试应在现代 Chromium 引擎中呈现的内容,但您应该能够 运行 所有 IE11 测试并验证呈现在微软边缘。请注意,此代码需要对 IEDriverServer 进行更新,该更新应包含在下一版本的 Selenium 中。
从 SeleniumHQ 下载新的 IEDriverServer 并按照 here 中“必需配置”的说明进行操作后,您可以 运行 以下代码在 IE11 模式下启动新的 Microsoft Edge和 运行 一些测试:
static void Main(string[] args)
{
var dir = "{FULL_PATH_TO_IEDRIVERSERVER}";
var driver = "IEDriverServer.exe";
if (!Directory.Exists(dir) || !File.Exists(Path.Combine(dir, driver)))
{
Console.WriteLine("Failed to find {0} in {1} folder.", dir, driver);
return;
}
var ieService = InternetExplorerDriverService.CreateDefaultService(dir, driver);
var ieOptions = new InternetExplorerOptions{};
ieOptions.AddAdditionalCapability("ie.edgechromium", true);
ieOptions.AddAdditionalCapability("ie.edgepath", @"\msedge.exe");
var webdriver = new InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(30));
webdriver.Url = "http://www.example.com";
}
输出:
备注:
确保您使用的是最新版本的 IE 驱动服务器。
我建议使用最新版本的 Stable Edge 浏览器进行测试。
尝试在'ie.edgepath'能力中传递Edge浏览器的完整路径。例如:
ieOptions.AddAdditionalCapability("ie.edgepath", @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe");
确保在 运行 代码之前关闭所有已打开的 Edge 浏览器实例和选项卡。否则会报错。
参考文献:
以下代码(在 VB.NET 中,但您可以轻松将其修改为 C#)将在 IE 模式下启动 Chromium Edge
Dim ieService = InternetExplorerDriverService.CreateDefaultService("DIRECTORY_PATH_HAVING_IEDriverServer.exe", "IEDriverServer.exe")
Dim ieOptions = New InternetExplorerOptions
ieOptions.IgnoreZoomLevel = True
ieOptions.AddAdditionalCapability("ie.edgechromium", True)
ieOptions.AddAdditionalCapability("ie.edgepath", "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
Dim driver = New InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(60))
driver.Navigate().GoToUrl("https://example.com")
下载IEDriverServer
您好,
我想通过在 EdgeDriver 中添加一个选项来实现这一点,但我似乎无法在地图上的任何地方找到它?
我正在尝试使用 Selenium 和 EdgeDriver 在 Edge 中以 IE 模式打开页面。
有没有办法实现这个伟大的事情? [双关]
我可以在这个帖子中看到 2 个问题。
- 有没有办法在 Edge 选项中激活 IE 模式?
无法绕过 Selenium Edge 驱动程序中的 Edge 选项参数来激活 IE 模式。
- 我正在尝试使用 Selenium 和 EdgeDriver 在 Edge 中以 IE 模式打开一个页面。有没有办法实现这个伟大的事情?
是的,可以使用 Selenium 网络驱动程序在新的 MS Edge 浏览器中自动执行 IE 模式。
新的 Microsoft Edge 允许您 运行 除了现代体验之外,还可以对旧网站进行 IE11 验证。要在 Microsoft Edge 中 运行 进行 IE11 测试,请从 Selenium 下载 IEDriverServer。然后您必须传递将 Microsoft Edge 置于 IE 模式的功能,然后 运行 您的测试。
因为此功能会将整个浏览器置于 IE11 模式,您无法同时测试应在现代 Chromium 引擎中呈现的内容,但您应该能够 运行 所有 IE11 测试并验证呈现在微软边缘。请注意,此代码需要对 IEDriverServer 进行更新,该更新应包含在下一版本的 Selenium 中。
从 SeleniumHQ 下载新的 IEDriverServer 并按照 here 中“必需配置”的说明进行操作后,您可以 运行 以下代码在 IE11 模式下启动新的 Microsoft Edge和 运行 一些测试:
static void Main(string[] args)
{
var dir = "{FULL_PATH_TO_IEDRIVERSERVER}";
var driver = "IEDriverServer.exe";
if (!Directory.Exists(dir) || !File.Exists(Path.Combine(dir, driver)))
{
Console.WriteLine("Failed to find {0} in {1} folder.", dir, driver);
return;
}
var ieService = InternetExplorerDriverService.CreateDefaultService(dir, driver);
var ieOptions = new InternetExplorerOptions{};
ieOptions.AddAdditionalCapability("ie.edgechromium", true);
ieOptions.AddAdditionalCapability("ie.edgepath", @"\msedge.exe");
var webdriver = new InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(30));
webdriver.Url = "http://www.example.com";
}
输出:
备注:
确保您使用的是最新版本的 IE 驱动服务器。
我建议使用最新版本的 Stable Edge 浏览器进行测试。
尝试在'ie.edgepath'能力中传递Edge浏览器的完整路径。例如:
ieOptions.AddAdditionalCapability("ie.edgepath", @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe");
确保在 运行 代码之前关闭所有已打开的 Edge 浏览器实例和选项卡。否则会报错。
参考文献:
以下代码(在 VB.NET 中,但您可以轻松将其修改为 C#)将在 IE 模式下启动 Chromium Edge
Dim ieService = InternetExplorerDriverService.CreateDefaultService("DIRECTORY_PATH_HAVING_IEDriverServer.exe", "IEDriverServer.exe")
Dim ieOptions = New InternetExplorerOptions
ieOptions.IgnoreZoomLevel = True
ieOptions.AddAdditionalCapability("ie.edgechromium", True)
ieOptions.AddAdditionalCapability("ie.edgepath", "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
Dim driver = New InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(60))
driver.Navigate().GoToUrl("https://example.com")
下载IEDriverServer