当我尝试在 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/