带有 InternetExplorerDriver 的 IE 模式

问题描述 投票:0回答:1

现在我在用

selenium version 4.8.1

使用以下代码:

var ieOptions = new InternetExplorerOptions { };

ieOptions.AttachToEdgeChrome = true;

ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings= true;

WebDriver driver = new InternetExplorerDriver(ieOptions);

driver.Navigate().GoToUrl("https://bing.com");

driver.FindElement(By.Id("sb_form_q")).SendKeys("Hello world");

driver.FindElement(By.Id("sb_form")).Submit();

When I run the code, the program stops and timeouts after 60 seconds at the line

driver.Navigate().GoToUrl("https://bing.com");

我已经咨询了几种方法,当我在 Internet 选项中关闭保护模式时,它就可以正常工作了。 有没有办法让我不必在 internet 选项中关闭保护模式,仍然可以正常运行?

selenium-webdriver internet-explorer-11 internet-explorer-driver
1个回答
0
投票

通常情况下,如果您已经指定

IntroduceInstabilityByIgnoringProtectedModeSettings = true
,则不必关闭保护模式。我未能使用我的 IE 驱动程序 4.8.1.0 重现此问题。这可能与您的 IE 驱动程序版本有关(您只说了 Selenium 4.8.1,但我不确定您的 IE 驱动程序版本)。如果您还没有安装最新版本的 IE 驱动程序,您可以尝试安装。

更新

我发现这似乎是一个普遍的问题,因为在您分享此问题后,其他地方也有报道。更改保护模式的注册表设置可能是解决方案之一。另一种可能的解决方案是直接导航到目标 URL,而无需等待来自本地主机的重定向。您可以尝试以下选项:

ieOptions.InitialBrowserUrl = "https://bing.com";
© www.soinside.com 2019 - 2024. All rights reserved.