C# Using extensions in the background browser

97 views
Skip to first unread message

Али Гасанов

unread,
Apr 26, 2024, 6:49:00 AM4/26/24
to Selenium Users
Hello, please tell me how to add extensions when using the "--headless" argument?

                    ChromeOptions chromeOptions = new();
                    chromeOptions.AddArgument("--headless");              
                    chromeOptions.AddExtension(Path.Combine(Environment.CurrentDirectory, "CryptoPro Extension for CAdES Browser Plug-in.crx"));
  ChromeDriver driver = new(chromeOptions);

If you do not use the headless argument, then everything will work correctly, but an error is generated when using it.

OpenQA.Selenium.WebDriverException
  HResult=0x80131500
  Сообщение = unknown error: failed to wait for extension background page to load: chrome-extension://iifchhfnnmpdbibifmljnfjhpififfog/_generated_background_page.html
from unknown error: page could not be found: chrome-extension://iifchhfnnmpdbibifmljnfjhpififfog/_generated_background_page.html
  Источник = WebDriver
  Трассировка стека:
   в OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
   в OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   в OpenQA.Selenium.WebDriver.StartSession(ICapabilities capabilities)
   в OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
   в OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
   в OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
   в OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
   в System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
Reply all
Reply to author
Forward
0 new messages