-->

Selenium ChromeDriver - is it possible to load mul

2019-07-18 22:19发布

问题:

(I'm new so don't kill me, please)

I'm trying to start ChromeDriver for a Chromium-based browser with multiple unpacked extensions, thus (simplified for your convenience, but basically the same as in the code):

   foreach (var path in ExtensionsPaths)
   {
    CommonWebDriver._ChromeOptionsForTorch.AddArguments(new string[1] { "--load-extension=" + path });
   }

After the foreach finishes running, I see all the extensions I want to load listed in the options.

When I create the ChromeDriver, though, it only loads one extension from this list - the last one of them.

What am I doing wrong? Is it possible to load multiple extensions?

回答1:

You could try:

ChromeOptions options = new ChromeOptions();

foreach (var path in ExtensionsPaths)
{
    options.AddExtensions(new File(path));
}


回答2:

You provide one argument string containing multiple paths to extensions separated by comma:

ChromeOptions options = new ChromeOptions();
options.AddArgument(@"load-extension=c:\PathToFirstExtensionHere,c:\PathToSecondExtensionHere");
Driver = new ChromeDriver(options);