首页 > 解决方案 > Heroku Only Dev Environment 有 Chrome 版本 81 问题

问题描述

我将 heroku 与 selenium 与 heroku/google-chrome 和 heroku/chromedriver buildpacks 一起使用。google chrome 最近有更新,google-chrome buildpack 也更新了。

编辑:我在我的开发实例上看到

/app/.apt/opt/google/chrome/chrome --version
Google Chrome 80.0.3987.163 unknown

但在我的产品实例上有效

Google Chrome 81.0.4044.92 unknown

所以问题是我如何在heroku上强制版本?

下面的旧信息现在可能不太相关了。

但是,尽管如此,我现在仍然看到 chrome 版本错误,但仅在我的开发实例上。当我直接使用我的生产实例构建时,它工作正常。但是,我的典型过程是使用我的开发实例构建和测试,然后将确切的构建提升到生产实例,现在将提升一个损坏的构建。

这是错误:

2020-04-09T22:20:56.505318+00:00 app[celery_worker.1]: [2020-04-09 22:20:56,504: ERROR/ForkPoolWorker-1] Task ... raised unexpected: SessionNotCreatedException('session not created: This version of ChromeDriver only supports Chrome version 81', None, None)
...
2020-04-09T22:20:56.505336+00:00 app[celery_worker.1]: 'CHROMEDRIVER_PATH', ''), chrome_options=chrome_options)
2020-04-09T22:20:56.505336+00:00 app[celery_worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/seleniumwire/webdriver/browser.py", line 88, in __init__
2020-04-09T22:20:56.505337+00:00 app[celery_worker.1]: super().__init__(*args, **kwargs)
2020-04-09T22:20:56.505337+00:00 app[celery_worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
2020-04-09T22:20:56.505338+00:00 app[celery_worker.1]: desired_capabilities=desired_capabilities)
2020-04-09T22:20:56.505338+00:00 app[celery_worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
2020-04-09T22:20:56.505339+00:00 app[celery_worker.1]: self.start_session(capabilities, browser_profile)
2020-04-09T22:20:56.505339+00:00 app[celery_worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
2020-04-09T22:20:56.505339+00:00 app[celery_worker.1]: response = self.execute(Command.NEW_SESSION, parameters)
2020-04-09T22:20:56.505340+00:00 app[celery_worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
2020-04-09T22:20:56.505340+00:00 app[celery_worker.1]: self.error_handler.check_response(response)
2020-04-09T22:20:56.505341+00:00 app[celery_worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
2020-04-09T22:20:56.505342+00:00 app[celery_worker.1]: raise exception_class(message, screen, stacktrace)
2020-04-09T22:20:56.505342+00:00 app[celery_worker.1]: selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81

据我所知,我的开发实例与我的生产实例基本完全相同,但显然情况并非如此。buildpacks 和 requirements.txt 完全相同,构建日志几乎相同我确实在构建日志中看到了这种差异,开发版本具有:

-----> Installing libasound2_1.1.3-5ubuntu0.2_amd64.deb
-----> Installing libasound2_1.1.3-5ubuntu0.4_amd64.deb
-----> Installing libasound2-data_1.1.3-5ubuntu0.2_all.deb
-----> Installing libasound2-data_1.1.3-5ubuntu0.4_all.deb

但生产版只有

-----> Installing libasound2_1.1.3-5ubuntu0.4_amd64.deb
-----> Installing libasound2-data_1.1.3-5ubuntu0.4_all.deb

不过,这似乎是一条红鲱鱼。

这是 heroku/google-chrome buildpack 中可能存在的一个相关问题: https ://github.com/heroku/heroku-buildpack-google-chrome/pull/85

还有其他人看到这个并且知道如何让开发版本工作或如何让 selenium 再次在 heroku 上工作吗?

标签: pythonseleniumgoogle-chromeherokuselenium-chromedriver

解决方案


我找到了解决办法,你需要重置你的缓存

$ heroku plugins:install heroku-repo

$ heroku repo:purge_cache -a appname

然后使用空提交重新部署或从 master 部署。

它仅在 dev 上失败的原因是因为我从未在我的生产堆栈上构建,因此它没有旧 chrome 版本的缓存。

https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache


推荐阅读