Could not start Chrome selenium "unknown error: cannot handle extension # 1"

I am trying to run the chrome selenium driver and add the extension:

manifest_json = """..... """
background_js = """...."""
ext_file = 'my_extention.zip'
with zipfile.ZipFile(ext_file, 'w') as zp:
    zp.writestr("manifest.json", manifest_json)
    zp.writestr("background.js", background_js)

co = webdriver.ChromeOptions()
co.add_extension(ext_file)
d = webdriver.Chrome(chrome_options=co)

This causes an error:

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot process extension #1
from unknown error: invalid public key length
  (Driver info: chromedriver=2.9.248304,platform=Linux 3.19.0-39-generic x86_64)
+4
source share
1 answer

I stumble on this problem when I tried to encode base64 to base64 in order to have an extension running in selenium (this was in the context of protractor trials).

I suspect that this is due to the fact that the extension does not apply to the same browser except the one that is trying to launch it.

In any case, I end the failure, and I just simply added the chrome option to load the extension without empacted:

--load-extension=path_to_the_extension_folder

Hope this helps.

+2

Source: https://habr.com/ru/post/1621854/


All Articles