我发现了这些构建包(http://github.com/douglasjsellers/heroku-xvfb-buildpack),但是按照说明似乎无法解决问题,因为xvfb仍未正确安装。此外,我尝试安装xvfbwrapper(https://pypi.python.org/pypi/xvfbwrapper/0.1.0),但在Heroku上仍无法正常工作(对于可能是新手的问题表示歉意)。
以下是我从Heroku日志中获取的错误:
2015-02-24T02:09:16.035298+00:00 app[web.6]: cmd=['Xvfb', '-help']
2015-02-24T02:09:16.035564+00:00 app[web.6]: Program install error!
2015-02-24T02:09:16.035302+00:00 app[web.6]: OSError=[Errno 2] No such file or directory
这里是代码:
temp = tempfile.mkstemp(suffix='.html')
html = os.fdopen(temp[0], "r+")
html.write(cv)
html.seek(0, 0)
display = Display(visible=0, size=(800, 600))
display.start()
# Open the file on Selenium to load the JavaScript
driver = webdriver.Firefox()
driver.get("file://" + temp[1])