Extensions installed in the Chrome browser are not available when opening an instance of the Chrome browser using Selenium chromeDriver

I have a special problem here. When I open chromeBrowser via chromeDriver, there are no previously installed extensions. Also, the application extension is deleted from the extensions folder (AppData \ Local \ Google \ Chrome \ User Data \ Default \ Extensions).

Now, when I open the Chrome browser manually, the extension appears in the browser, as well as the application folder in the extensions folder (AppData \ Local \ Google \ Chrome \ User Data \ Default \ Extensions).

Below is the version of the chrome driver and browser. chromedriver version: 26.0.1383.0 chrome browser: 26.0.1410.64

+8
source share
4 answers

Parameters ChromeOptions = new ChromeOptions (); options.AddAdditionalCapability ("excludeSwitches", new object [] {"disable-default-apps"});
IWebDriver drv = new ChromeDriver (options);

available from webdriver.net 2.40 bindings and beyond.

0
source

You need to install each extension that you want to use. In Selenium2 C # API, it looks like

var options = new ChromeOptions(); options.AddExtension(Path.GetFullPath("local/path/to/extension.crx")); var driver = new ChromeDriver(options); 

and the extension will be in the browser. Link to java can be found here . See this question on how to get the .crx file for your extension from the chrome repository.

+8
source

this answer can be found here https://sites.google.com/a/chromium.org/chromedriver/extensions . Chrome extensions can be packaged or unpacked. Packed extensions are one file with a .crx extension. Unpacked extensions is the directory containing the extension, including the manifest.json file.

To pack the unpacked extension, use the "Pack" button in the chrome: // extensions or use Chrome: "chrome.exe --pack-extension = C: \ path \ to \ unpacked \ extension --pack-extension-key = C: \ myext.pem ". See the extension documentation for other ways to make it more automation-friendly. To unzip the packaged extension, simply unzip the file (you may need to rename the file from .crx to .zip for your zip utility to recognize it). Install extensions through ChromeDriver

Packed (.crx file)

 ChromeOptions options = new ChromeOptions(); options.addExtensions(new File("/path/to/extension.crx")); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); ChromeDriver driver = new ChromeDriver(capabilities); 

Unpacked (catalog)

 ChromeOptions options = new ChromeOptions(); options.addArguments("load-extension=/path/to/extension"); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); ChromeDriver driver = new ChromeDriver(capabilities); 
+4
source

If you want the extension to be available during testing, you need to run chrome with the profile that defines this extension, or provide the extension as a necessary property to the web director. Usually, when you start chrome using webdriver, chrome starts with a new profile every time.

so if you want to download the extension in test chrome do the following:

  DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("chrome.switches", Arrays.asList("--load-extension=/path/to/extension/directory")); WebDriver driver = new ChromeDriver(capabilities); 

Learn more about this here.

+2
source

All Articles