Load chrome extension using selenium

I am not sure why you are particular about downloading from Webstore and then install into Chrome.

I found some steps to download chrome extensions:

-With a computer connected to the internet, install the extension from the extension page: https://chrome.google.com/webstore/detail/
-Navigate to the extension source code. In XP this is found at: C:\Documents and Settings\\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions\
-You should see a version folder (ie. “0.0.21_0”). Copy this folder and move it on the machine you want to install on.
-Open up chrome on the disconnected machine and go to Wrench -> Tools -> Extensions
-Click the + next to Developer mode to display the developer options
-Click ‘Pack extension…’ and choose the version folder as the root directory. Leave the private key file blank. This will create a .crx file in the version folder along with a private key as if you were the developer.

–Or–

1- Find the ID of the extension you’re interested in. When on the details page of the extension, it will be something like :
bfbmjmiodbnnpllbbbfblcplfjjepjdn
after
https://chrome.google.com/webstore/detail/

2- Paste this into any other browser (not Chrome):
https://clients2.google.com/service/update2/crx?response=redirect&x=id%3D~~~~%26uc

3- and replacing ~~~~ with the extension ID.
You’ll be prompted to save a CRX file. Drag this file to a Chrome window and proceed with installation.

Source: https://productforums.google.com/forum/#!topic/chrome/g02KlhK12fU

Finally, use the downloaded .crx file in ChromeOptions to load the extension

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);

Source: https://sites.google.com/a/chromium.org/chromedriver/extensions

Leave a Comment