【问题标题】:Deploying selenium on heroku (Chrome binary not detected)在 heroku 上部署 selenium(未检测到 Chrome 二进制文件)
【发布时间】:2018-04-06 04:52:23
【问题描述】:

我正在尝试在 heroku 上使用烧瓶部署 selenium 脚本。

我添加了以下构建包

  1. https://github.com/heroku/heroku-buildpack-xvfb-google-chrome
  2. https://github.com/heroku/heroku-buildpack-chromedriver

我还创建了配置变量:

  1. CHROMEDRIVER_PATH = "/my-app/.chromedriver/bin/chromedriver"
  2. GOOGLE_CHROME_SHIM = "/my-app/.apt/usr/bin/google-chrome"

下面是引用chromedriver的Python sn-p:

chrome_bin = os.environ.get('GOOGLE_CHROME_SHIM', None)
opts = ChromeOptions()
opts.binary_location = chrome_bin
browser = webdriver.Chrome(executable_path="chromedriver", chrome_options=opts)  

但是当我打开我的应用程序时发生以下错误:

WebDriverException:消息:未知错误:/tmp/build_4cef63dfa1c952837ceb30f2e894524a/.apt/usr/bin/google-chrome-stable` 处没有 chrome 二进制文件

请帮忙!!!!

【问题讨论】:

  • 你不应该在 heroku 上使用 selenium,它不适合它。获取 browserstack、saucelabs 等在线服务,然后使用远程 webdriver

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


【解决方案1】:

GOOGLE_CHROME_SHIM 在配置中设置错误。 请改用以下配置。

opts.binary_location = "/app/.apt/usr/bin/google-chrome-stable"

这对我有用。

【讨论】:

    猜你喜欢
    • 2023-04-01
    • 2018-12-16
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    • 2021-01-19
    • 2012-07-15
    • 2022-07-04
    • 1970-01-01
    相关资源
    最近更新 更多