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);
Kevin do
source share