c# - 有没有办法将 chrome-extension 添加到 PuppeteerSharp Web 驱动程序?

标签 c# puppeteer-sharp

如何将 Chrome 扩展加载到 PuppeteerSharp 的驱动程序中, 类似于Selenium的选项:

ChromeOptions options = new ChromeOptions();
options.AddExtension(@"C:\a\path\to\file.zip");

最佳答案

基于Line 43 of the LanchOptions.cs您可以指定启动过程的参数。

现在将其与 native JavaScript 连接(使用 --load-extension flag ),输出应类似于以下内容:

var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
    Args = new string[1] { "--load-extension=/Path/To/Extension/Folder" }
});

注意:我将路径放在文件夹中,而不是示例中的 .zip。如果您想加载多个扩展名,则只需使用逗号分隔路径即可。

Here's a full list of possible arguments that can be passed in to Chromium.

关于c# - 有没有办法将 chrome-extension 添加到 PuppeteerSharp Web 驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52151078/

相关文章:

c# - puppeteer 师夏普 : Multiple Browsers Concurrently

c# - 在 .NET 世界中开始学习 C# 还是 C++ 更好?

javascript - 登录控制,通过按键设置onauthenticate ="LoginAuthenticateEvent"

c# - 为什么委托(delegate)类型派生自 MulticastDelegate 类为什么不直接派生自 Delegate 类?

c# - 是否可以有一个仅在应用程序运行时才存在的目录?

c# - 使用 PuppeteerSharp 访问 windows.localStorage

puppeteer-sharp - IIS 中的 PuppeteerSharp

c# - Puppeteer 中 LaunchAsync() 的线程安全

c# - 当我放在启动文件夹中时,EXE 的行为有所不同

c# - Web API Controller 返回任务并不总是等待任务完成(puppeteer-sharp)