Reputation: 47
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.
Upvotes: 2
Views: 1576
Reputation: 3093
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
}
}
Upvotes: 2