python - 无法使用 Selenium 安装某些 Firefox 扩展

标签 python firefox selenium selenium-webdriver

当我尝试在 Python 上使用 Selenium 安装 Firefox 扩展时,我尝试安装的大约 50% 的扩展会收到 IOError: [Errno 13] Permission returned 错误。例如,当我尝试安装最新版本的 firebug 时,使用命令:

 firefox_profile.add_extension(working_director + "\\firebug-2.0.11-fx.xpi")

我收到错误:

 File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 265, in _install_extension
with open(os.path.join(tmpdir, name), 'wb') as f:
 IOError: [Errno 13] Permission denied: 'c:\\users\\USERNAME\\appdata\\local\\temp\\tmpxu73xr.firebug-2.0.11-fx.xpi\\content/firebug/'

(注意,Firebug 2.0.9 版本不会发生这种情况,它工作正常)

尝试安装quickjava (quickjava-2.0.6-fx) 和imageblock (imageblock-2.1-fx) 时,我遇到类似的错误。我怀疑错误源自安装路径末尾的 / (而不是其他地方的 \\),即 ...temp\\tmpxu73xr .firebug-2.0.11-fx.xpi\\content/firebug/

无法理解为什么我的某些扩展没有问题。为那些不起作用的问题寻找解决方法。作为引用,我在 Windows 上使用 Firefox 39 和 Selenium 2.46.0

最佳答案

感谢 @sandwich Heat 最初发布了部分答案(在他/她或其他人删除它之前) - 这是 Salenium 的一个错误 - https://github.com/SeleniumHQ/selenium/issues/734

此问题已在 github 页面 https://github.com/SeleniumHQ/selenium/blob/master/py/selenium/webdriver/firefox/firefox_profile.py 上修复但到目前为止尚未进入 Selenium 的稳定版本(2.46.0)

因此,我通过用 Github 上的文件替换 firefox_profile.py 解决了我的问题。

关于python - 无法使用 Selenium 安装某些 Firefox 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31574211/

相关文章:

Selenium 点击 Highcharts 系列

javascript - 如何在 JavaScript 中从 Selenium 中具有特定类的标签获取内容

python - 在同一事务上读取和修改 - Bigtable

python - Numpy ndarray 在 bool 条件之后进行广播

python - 使用负索引在 Python 中访问整个字符串

python - 如何使用 pandas df.plot.scatter 制作带有子图的图形

java - 为什么 Firefox 会在 20 秒后终止我的小程序?

html - 由 CSS 剪辑引起的闪烁微调器?

selenium - org.openqa.selenium.SessionNotCreatedException : Unable to find a matching set of capabilities while initiating Firefox v37 through Selenium v3. 11.0

java - Selenium /java : how to get get total page length