2
votes

I am trying to deploy selenium script using flask on heroku.

I added the following buildpacks

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

And I also created config variables as:

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

And below is the Python snippet for referring to chromedriver:

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)  

But when i open my app following error occurred:

WebDriverException: Message: unknown error: no chrome binary at /tmp/build_4cef63dfa1c952837ceb30f2e894524a/.apt/usr/bin/google-chrome-stable`

PLEASE HELP!!!!

1
You should not use selenium on heroku, it is not meant for it. Get a online service like browserstack, saucelabs or something else and then use remote webdriver - Tarun Lalwani

1 Answers

1
votes

GOOGLE_CHROME_SHIM is set wrongly in the config. Use the below config instead.

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

That worked for me.