Heroku Only Dev Environment具有Chrome版本81问题

时间:2020-04-09 22:32:53

标签: python selenium google-chrome heroku selenium-chromedriver

我在heroku / google-chrome和heroku / chromedriver buildpacks中使用带有硒的heroku。谷歌浏览器最近进行了更新,而谷歌浏览器buildpack也已更新。

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

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

但在我的生产实例上有效

Google Chrome 81.0.4044.92 unknown

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

下面的旧信息现在可能不那么重要了。

但是,尽管如此,我现在仍然看到chrome版本错误,但仅在我的dev实例上。当我直接使用生产实例进行构建时,它可以正常工作。但是,我的典型流程是使用我的dev实例进行构建和测试,然后将该确切的构建升级到生产实例,而现在该生产实例将升级损坏的构建。

这是错误:

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

据我所知,我的dev实例与我的生产实例基本上完全相同,但显然并非如此。 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

其他人看到了这一点,并且知道如何使开发人员构建正常工作或如何让硒再次在heroku上工作吗?

1 个答案:

答案 0 :(得分:4)

我想出了解决办法,您需要重置缓存

$ 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