2

I've just started using this port for puppeteer but I have a problem. When I put the flag "--incognito" or if I use the browser.CreateIncognitoBrowserContextAsync() I always get 2 chrome windows opened. There is a fix for this issue ? If I do this to my chrome broswer using "--incognito" flag it will open only 1 instance.

atoms
  • 2,993
  • 2
  • 22
  • 43
ginko
  • 47
  • 6

1 Answers1

1

It's rather messy but this seems to work..

using (Browser browser = await Puppeteer.LaunchAsync(options))
{
     // create the async context 
    var context = await browser.CreateIncognitoBrowserContextAsync();

    // get the page created by default when launch async ran and close it whilst keeping the browser active
    var browserPages = await browser.PagesAsync();
    await browserPages[0].CloseAsync();

    // create a new page using the incognito context
    using (Page page = await context.NewPageAsync())
    {
        // do something 
    }
}
atoms
  • 2,993
  • 2
  • 22
  • 43