'Selenium RemoteWebDriver() ERR_BLOCKED_BY_CLIENT on Chrome Extension in Selenium Grid, while without ChromeExtension works fine

We are using an extension in chrome for wiremock. This chrome extension works beautifully while running locally both on Windows ( ref. 1), Mac computers. However when instantiating RemoteWebDriver() in a Selenium Test Grid flavor named Moon, loading the extension fails (on Linux) catastrophically with ERR_BLOCKED_BY_CLIENT when trying to load the chrome extension.

(ref. 1) On Windows localhost , execution actually fails with a message "That unpacked extensions is disabled by the admin"" but this can be easily workarounded by manually deleting a key at : Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallBlacklist https://support.leapwork.com/hc/en-us/articles/360003031952-How-to-resolve-Error-Loading-of-unpacked-extensions-is-disabled-by-the-administrator

**- So I guess one needs to do something similar in the Test Grid node running Linux, but how does that code look like exactly? **

We have a switch statement in the code, so we see that code works generally fine in the test grid when tests are instantiated without the chrome extension.

Junit4.x com.github.tomakehurst wiremock-jre8 2.32.0 jdk8 (we have so many indirect dependencies on about 77 or so different artifact versions so updating is almost impossible. (I suspect I will get the Nobel price in physics before that happens)

Chrome version 91.0.4472 is instantiated in the grid.

Error message : idgpnmonknjnojddfkpgkljpfnnfcklj is blocked. This page has been blocked by Chrome. ERR_BLOCKED_BY_CLIENT”

We have tried a few different code constructs which all failed to unblock the extension from loading.

Here is one such code example we unsuccessfully tried with:

private RemoteWebDriver createDriver( Scenario scenario) {
      RemoteWebDriver driver = null;

      ChromeOptions options = mock ?
              new ChromeOptions()
                      .addExtensions(new File("src/test/resources/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj.crx")) :
              new ChromeOptions();

      options.setPageLoadStrategy(PageLoadStrategy.EAGER);


      DesiredCapabilities capabilities = new DesiredCapabilities();
      capabilities.setCapability(ChromeOptions.CAPABILITY, options);


      Proxy proxy = new Proxy();
      proxy.setHttpProxy("http://proxy.aaaaaaaaaaaaaaaa.com:8080");
      proxy.setSslProxy("http:// proxy.aaaaaaaaaaaaaaaa.com:8080");");
      proxy.setNoProxy("");
      capabilities.setCapability("proxy", proxy);

      capabilities.setCapability("enableVNC", true);
      capabilities.setCapability("name",  String.format("TEST - %s", scenario.getName()));

      System.setProperty("selenide.remote","https://grid.aaaaaaaaaaaaaaaa.com/wd/hub");
      System.setProperty("selenide.browser", "chrome");
      System.setProperty("selenide.proxyHost", "proxy.aaaaaaaaaaaaaaaa.com ");
      System.setProperty("selenide.proxyPort", "8080");
      System.setProperty("selenide.proxyEnabled", "true");

      if (System.getProperty("debugMoon") != null && System.getProperty("debugMoon").length()>0) {
          capabilities.setCapability("devtools", true); 
          capabilities.setCapability("noExit", true);
          System.setProperty("devtools", "true");
          System.setProperty("noExit", "true");
          System.setProperty("moon_debugged", "true");
      }
  //  options.merge(capabilities);  
      try {
          if(mock) {   addHeaderMock();  }   // adding header before Chromedriver new () when started in the MOON test Grid

          logger.info("***********  Grid ***********");
          final URL url = new URL("https://grid.aaaaaaaaaaaaaaaa.com/wd/hub");
          logger.info(">>> Connecting to Moon test grid url: " + url.toString());
          driver = new RemoteWebDriver(url, capabilities) );    // have tried both capabilities object but also options.merge(capabilities) with no joy


      } catch (final Exception e) {
                  logger.info("Unable to create driver " + e);
      }
      logger.info("Connection established\n");
      return driver;
  }

ERR_BLOCKED_BY_CLIENT_IN_SELENIUM_GRID

Any hints or pointers in the right direction are much appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source