How to load Chrome extension in Chrome on Selenoid

There is a topic on how to load a custom chrome extension.

It works locally.

When using the selenoid helper

selenoid: {
  enabled: true,
  deletePassed: true,
  autoCreate: true,
  autoStart: true,
  sessionTimeout: '10m',
  enableVideo: true,
  enableLog: true,
  enableVnc: true
}

per the behavior of the tests and screenshots, I can see the extension has not been loaded. I found in a selenoid log

Launching chrome: /usr/bin/google-chrome --disable-background-mode --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-gpu --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --ignore-certificate-errors –load-extension=/Users/MyUser/e2e_tests/extension_folder,/tmp/.com.google.Chrome.LHzt0x/internal --log-level=0 --no-first-run --no-sandbox --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.WOPPIL --window-size=1200,1000 data:,

So, 2 extensions were passed --load-extension=<my path to the folder with unpacked extension>,/tmp/.com.google.Chrome.LHzt0x/internal

Does it mean, my extension has to be uploaded to /tmp/ anyhow?

If this is that a packaged extension works only, what google key should be used with it?

Found the solution. Leaving my question and answer here, in case anyone else runs into the same issue.

--load-extension key is for folders with unpacked extensions.
The packed extensions must be specified in
['desiredCapabilities']['chromeOptions']['extensions'] array

And Selenoid appeared to work with packed extensions only.

Moreover, specifying just a path to the file does not work because of a bug resulting in
cannot process extension #1 ... cannot base64 decode
It can be workarounded by specifying the file contents to the option

  const fs = require('fs');
  const file = fs.readFileSync('./ext.crx', { encoding: 'base64' })
  driverConfig['desiredCapabilities']['chromeOptions']['extensions'].push(file);

Hello bro
I’m getting the same error but didn’t understand well your solution
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: cannot process extension #1
from unknown error: cannot base64 decode

Here is my script :

capabilities = {
"browserName": "chrome",
"version": "81.0",
"enableVNC": True,
"enableVideo": True,
"goog:chromeOptions": {
"args": ["disable-infobars", "start-maximized"],
"extensions": [r'C:\Users\SAMSUNG\Dropbox\SB.crx'],
"prefs": {
"profile.default_content_setting_values.media_stream_mic": 2,
"profile.default_content_setting_values.media_stream_camera": 2,
"profile.default_content_setting_values.geolocation": 2,
"profile.default_content_setting_values.notifications": 2
}
}}

driver = webdriver.Remote(command_executor="[http://Selenoid/wd/hub](http://selenoid/wd/hub)",
desired_capabilities=capabilities)

@hamzosb hello
Did you check the extesion works without Selenoid? Can it be successfully unzipped by any archiver?