How can I load a chrome extension to PuppeteerSharp's driver, similar to Selenium's option:
ChromeOptions options = new ChromeOptions();
options.AddExtension(@"C:\a\path\to\file.zip");
How can I load a chrome extension to PuppeteerSharp's driver, similar to Selenium's option:
ChromeOptions options = new ChromeOptions();
options.AddExtension(@"C:\a\path\to\file.zip");
Based on Line 43 of the LanchOptions.cs you can specify arguments to the launch process.
Now connecting this with the native JavaScript (using the --load-extension flag) the output should look similar to the following:
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Args = new string[1] { "--load-extension=/Path/To/Extension/Folder" }
});
Note: that I put path to folder, not the .zip as you have in your sample.. if you want to load multiple extensions then just separate the paths using a comma.
Here's a full list of possible arguments that can be passed in to Chromium.
According to this issie, next piece of code works for me:
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Args = new string[1]
{
"--disable-extensions-except=${pathToExtension}",
"--load-extension=${pathToExtension}"
}
});
Sometimes it can't load some extensions when they are packed (*.crx or *.zip files). Then unpacking this extensions can help.