I created a simply Flask app with Selenium deployed on Heroku. Esentially the schema is the following:
from flask import Flask, render_template
from flask import jsonify
from flask import request
from market_data import *
app = Flask(__name__, static_url_path='/static')
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True
def Collection(slug):
s=Service(GeckoDriverManager().install())
options = Options()
options.headless = True
driver = webdriver.Firefox(service=s, options=options)
#bla bla bla
return result
@app.route('/collection', methods=['GET'])
def Collection():
#taking request's parameters as input
slug = request.args.get('slug', None)
result = Collection(slug)
return result
As I try to run the app, heroku shows 500 Internal server error. From the logs I got the following error:
selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
So I tried the following installation [as seen from the documentation][1]
heroku create --buildpack https://github.com/ronnielivingsince1994/heroku-integrated-firefox-geckodriver
heroku config:set FIREFOX_BIN=/app/vendor/firefox/firefox
heroku config:set GECKODRIVER_PATH=/app/vendor/geckodriver/geckodriver heroku config:set LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib:/app/vendor
heroku config:set PATH=/usr/local/bin:/usr/bin:/bin:/app/vendor/
But still got the same error. How to fix it? Thanks for reading. This question obviously IS NOT for corresponding error running the script locally. So actually there's no answer on the web. [1]: https://elements.heroku.com/buildpacks/gordiansoftware/heroku-integrated-firefox-geckodriver