Search code examples
c#internet-explorerwatin

Watin Internet Explorer how to start in-private mode?


I am writing a few automated web tests using C# Watin framework.

I was hoping anyone can help me out,

How do i open new IE instance in "in private" browse mode? (i.e incognito mode)

The need for "in private" browsing, is because some of the tests, require log in. (and i run a few in parallel)

I could not find any resources on the matter. (other than half patch i found in some forum)

Thanks for your help!


Solution

  • The only solution i was able to find, is to open IE instance via command in incognito mode, then attach Watin to it.

        //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");