【发布时间】:2018-07-21 06:15:33
【问题描述】:
我正在尝试在 heroku 上设置 selenium。我一直在寻找Running ChromeDriver with Python selenium on Heroku 寻求帮助。基于此,我安装了列出的 2 个构建版本。我正在使用 cedar-14,因为不支持 16 堆栈。
当我跑步时:
$ heroku buildpacks
=== Buildpack URLs
1. heroku/python
2. https://github.com/heroku/heroku-buildpack-chromedriver
3. https://github.com/heroku/heroku-buildpack-xvfb-google-chrome
无论如何我都在尝试使用
https://github.com/heroku/heroku-buildpack-chromedriver/tree/master/bin
我的代码包含:
options = webdriver.ChromeOptions()
CHROMEDRIVER_PATH = os.getenv('$HOME') or basedir+'/chromedriver.exe'
FLASK_CONFIG = os.getenv('FLASK_CONFIG')
if FLASK_CONFIG and FLASK_CONFIG == "production":
options.binary_location = os.getenv('$GOOGLE_CHROME_SHIM')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=options)
此代码在本地运行良好,但在 heroku 上:
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=options)
2018-02-10T16:37:32.121783+00:00 app[web.1]: selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
如何在 buildpack 中设置 chromedriver 的路径?
【问题讨论】:
标签: python selenium heroku selenium-chromedriver