1
votes

I need to use one chrome extension from Chrome Store in my test on Selenium Grid in Chrome browser, but I have some troubles :(

  1. I tried to go to extension URL in browser (https://chrome.google.com/webstore/detail/...) and press key Install, but I can't confirm install in popup browser window
  2. I tried to download crx extension file, but then i open it in browser I saw confirm windows and do not understand how to confirm installation
  3. I tried to use this method - https://developer.chrome.com/extensions/external_extensions add JSON file and run browser - don't work, but I try it on Mac, not Linux
  4. webdriver.remote can use only FireFox options (seleniumhq.github.io/selenium/docs/api/py/webdriver_remote/selenium.webdriver.remote.webdriver.html)

If I use Selenium Grid I can't change Chrome browser start settings, can't add any keys :(

Maybe you know another method to install the extension on Selenium Grid browser session?

1

1 Answers

2
votes

You can use ChromeOptions.

ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("/path/to/extension.crx"));
ChromeDriver driver = new ChromeDriver(options);

Alternatively, you can add the options to an already existing DesiredCapabilities object.

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

You could also use a remote web driver:

DesiredCapabilities capability = DesiredCapabilities.chrome();
// above code goes here...
WebDriver driver = new RemoteWebDriver(new URL(hubUrl), capability);