There are 2 ways to add a Chrome plugin to a Selenium test:
options.addExtensions(new File("/path/to/extension.crx")); options.addArguments("load-extension=/path/to/extension"); The second is preferable due to preserving resources (to prevent unpacking the crx file), which will prevent "out of memory" errors for large extensions. The sample code offered at https://sites.google.com/a/chromium.org/chromedriver/extensions can be simplified further: ChromeOptions options = new ChromeOptions(); options.addArguments("load-extension=C:\\Users\\user\\..."); WebDriver driver = new ChromeDriver(options); driver.get("http://website.com");
Here is code to consider to use a subfolder called "chromeExtensions" in the main test folder:
options.addArguments("load-extension=" + System.getProperty("user.dir") + File.separator + "chromeExtensions" + File.separator + "screencastify");
The hardest part might be getting an unpacked version of the plugin. Here are 2 options:
1. Copy the extension folder from the Chrome profile.
2. Download the .crx file and unzip it For #1, you can visit chrome://version to obtain the path to the profile. You will find an extension folder that will match the name of the key found in the chrome plugin url, for example: https://chrome.google.com/webstore/detail/screencastify-screen-vide/mmeijimgabbpbgpdklnllpncmdofkcpn has this name: mmeijimgabbpbgpdklnllpncmdofkcpn. For #2, you may want to consider chrome-extension-downloader.com for the download and 7-zip.org to unzip it.
1 Comment
5/26/2022 06:42:36 am
Greating of the day Team, I was looking for the exact method of adding the Chrome plugin to the Selenium integration. After I looked your blog, I can understant the process clearly. And URLs that you have given was easy to proceed the installation without any difficulty. Thank you for your URLs to follow!!!
Reply
Leave a Reply. |