c# - Puppeteer sharp is opening 2 chrome windows on incognito
问题描述
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.
解决方案
它相当混乱,但这似乎有效..
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
}
}
推荐阅读
- apache - 无法启动传输“WebSockets”:null,Plesk Apache
- java - 如何将json序列化为Map?
- llvm-ir - LLVM:“MachineBasicBlock::getBasicBlock()”什么时候返回 nullptr?
- powerbi - 在 Power Bi 中创建来自不同数据集的 2 列总和的新列
- amazon-web-services - Kubenetes AWS EKS 仅将所有 Pod 分配到一个节点,而让另一个节点空闲
- google-cloud-platform - 如何按请求捆绑 Cloud Logging 条目?
- powershell - “启动进程:由于错误无法运行此命令:访问被拒绝。” 指定凭据时?
- file - 如何使用 GtkFileChooserWidget 选择文件
- javascript - [对象节点列表]是什么意思?
- microsoft-graph-api - 无法使用 microsoft graph api 发布 Teams 应用 zip 包