无法运行Chrome硒"未知错误:无法处理扩展程序1" [英] Unable to run Chrome selenium " unknown error: cannot process extension #1"

查看:168
本文介绍了无法运行Chrome硒"未知错误:无法处理扩展程序1"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行chrome硒驱动程序并添加扩展:

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)

这会引发错误:

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)

推荐答案

当我试图对.crx进行base64编码以使扩展在硒上运行时(在量角器测试的背景下),我偶然发现了这个问题).

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.

无论如何,我最终都放弃了,只是我向Chrome添加了一个选项来加载未实现的扩展程序:

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

希望对您有帮助.

这篇关于无法运行Chrome硒"未知错误:无法处理扩展程序1"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆