0

在使用 Selenium C# 运行我的自动化测试时,我试图在 InPrivate 模式下启动 IE11。找到了执行此操作的选项,但我似乎无法使用这些代码行。

        InternetExplorerOptions options = new InternetExplorerOptions();
        options.ForceCreateProcessApi = true;
        options.BrowserCommandLineArguments = "-private";

        IWebDriver driver = new InternetExplorerDriver(options);
        return driver;

驱动程序打开,我可以在任务管理器上看到它,但是 IE 没有打开。如果我在 InternetExplorerDriver 中删除选项,它完全可以正常工作。所以选项有问题。你对此有什么想法吗?

谢谢!

4

1 回答 1

2

相当老的话题,但万一有人仍然需要它......我偶然发现了一个类似的问题。

检查您是否使用的是 32 位 IE 驱动程序。我发现了options.ForceCreateProcessApi = true; 导致此驱动程序超时的困难方法,至少对于我测试过的版本(3.4.0 - 3.8.0)。到目前为止,我还没有设法在此设置中让私有模式适用于 32 位。

现在,我将其用作解决方法:

options.EnsureCleanSession = true;

这会大大降低测试速度,但至少会清除缓存。

于 2018-02-20T16:09:14.430 回答