简体   繁体   English

Selenium C#InPrivate模式Internet Explorer

[英]Selenium C# InPrivate Mode Internet Explorer

I'm trying to launch IE11 on InPrivate mode when running my automated tests using Selenium C#. 使用Selenium C#运行自动测试时,我试图以InPrivate模式启动IE11。 Found the options to do it but I can't seem to make mine work with these line of codes. 找到了执行此操作的选项,但我似乎无法使我使用这些代码行。

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

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

The driver opens as I can see it on task manager, but then IE does not open. 在任务管理器上可以看到该驱动程序,但是IE无法打开。 If I remove options though inside the InternetExplorerDriver, it works totally fine. 如果我通过InternetExplorerDriver删除了选项,则可以正常工作。 So there's something wrong with options. 因此,选项存在问题。 Would you have any idea about this? 您对此有任何想法吗?

Thanks! 谢谢!

Quite an old topic, but in case someone still happens to need it... I stumbled upon a similar issue. 很老的话题,但是万一有人碰巧需要它……我偶然发现了一个类似的问题。

Check if you are using the 32-bit IE driver. 检查您是否正在使用32位IE驱动程序。 I found out the hard way that options.ForceCreateProcessApi = true; 我发现options.ForceCreateProcessApi = true;的困难方式options.ForceCreateProcessApi = true; will cause this driver to timeout, at least for the versions I have tested (3.4.0 - 3.8.0). 至少在我测试过的版本(3.4.0-3.8.0)中,此驱动程序将超时。 So far, I haven't managed to get private mode working for 32-bit in this setting. 到目前为止,在这种设置下,我还没有设法使私有模式适用于32位。

For now, i use this as a work-around: 现在,我将其用作解决方法:

options.EnsureCleanSession = true;

This slows the tests down a lot, but at least it clears the cache. 这会大大降低测试速度,但至少会清除缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM