【问题标题】:C# WebDriver Internet Explorer, How to execute in silent mode?C# WebDriver Internet Explorer,如何在静默模式下执行?
【发布时间】:2013-12-23 18:19:41
【问题描述】:

在 C# 中使用 Internet Explorer Webdriver 时,服务器启动时会输出此消息:

启动 InternetExplorerDriver(64 位)

2.39.0.0

监听 37227 端口

我发现有命令行开关 --silent 在服务器启动时抑制诊断输出 (https://code.google.com/p/selenium/wiki/InternetExplorerDriver)。

我没有找到如何使用此命令行启动 Internet Explorer 驱动程序。

我的 C# 代码

InternetExplorerOptions optionsIE = new InternetExplorerOptions();
optionsIE.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
IWebDriver WebDriver = new InternetExplorerDriver(optionsIE);

我不想看到这些消息,我该如何隐藏它们?

感谢您的帮助。

【问题讨论】:

  • 你为什么要压制这些?这些消息只是为了您的利益
  • 因为我分析(解析)控制台输出。而这种类型的显示使解析复杂化

标签: c# internet-explorer selenium selenium-webdriver


【解决方案1】:

这应该接近你想要的代码。 “服务”可执行文件(如 IEDriverServer.exe)的命令行选项是通过相应的服务类设置的。

// WARNING: Done from memory without benefit of an IDE.
// May not be entirely accurate, or even compile as written.
InternetExplorerDriverService service = InternetExplorerDriverService.CreateDefaultService();
service.SuppressInitialDiagnosticInformation = true;

InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;

IWebDriver driver = new InternetExplorerDriver(service, options);

作为旁注和公共服务公告,如果您要设置IntroduceInstabilityByIgnoringProtectedModeSettings 选项,请You're Doing It Wrong

【讨论】:

  • 但如果我没有将 IntroduceInstabilityByIgnoringProtectedModeSettings 设置为 true,则会出现异常“启动 Internet Explorer 时出现意外错误。所有区域的保护模式设置都不相同。启用保护模式必须设置为相同的值(为所有区域启用或禁用)。(NoSuchDriver)"
  • 阅读答案中链接的博文。在这里,我会link to it again。它解释了为什么会出现该错误,为什么存在绕过选项,以及为什么配置某些东西至关重要,这样您就不必使用它。
  • 吉姆,没关系。我选中了标有“启用保护模式”的复选框。对于每个区域并在我的 C# 代码中抑制 IntroduceInstabilityByIgnoringProtectedModeSettings 选项。
【解决方案2】:

试试这个:

optionsIE.ForceCreateProcessApi = true;
optionsIE.BrowserCommandLineArguments = "--silent";

【讨论】:

  • 赫拉斯,没有成功!始终是消息
猜你喜欢
  • 2013-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多