Skip to main content
 首页 » 编程设计

c#之Watin Internet Explorer 如何启动私密模式

2024年08月12日58lvdongjie

我正在使用 C# Watin 框架编写一些自动化网络测试。

我希望有人能帮助我,

如何在“私密”浏览模式下打开新的 IE 实例? (即隐身模式)

需要“私密”浏览,是因为一些测试需要登录。(我同时运行了几个)

我找不到关于此事的任何资源。 (除了我在一些论坛上找到的半个补丁)

感谢您的帮助!

请您参考如下方法:

我能找到的唯一解决方案是在隐身模式下通过命令打开 IE 实例,然后将 Watin 附加到它。

    //gen random url so we can find the window later 
    Random rnd = new Random(); 
    int id = rnd.Next(1000, 10000);  
    string url = "id" + id+".com"; 
    //opening explorer 
    Process.Start("IExplore.exe", "-private -nomerge " + url); 
    browser = Browser.AttachTo<IE>(Find.ByUrl(new Regex(url))); 
    browser.GoTo("http://www.google.com");