如何将 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/