Reputation:
I'm trying to run a chrome selenium driver and add an extention:
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)
That throws 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)
Upvotes: 5
Views: 6629
Reputation: 2102
I stumble on that issue when I was trying to base64 encode a .crx in order to have the extension running on selenium (that was in the context of protractor tests).
I suspect this is due to the extension not being empacted with the same browser than the one trying to run it.
Anyway I end up giving-up and just I just added an option to chromium to load the un-empacted extension:
--load-extension=path_to_the_extension_folder
I hope it helps.
Upvotes: 3