So I have a Flask server on Heroku which has been working fine as expected for some time.Now, as per new requirements, I need to add functionality to the Flask server to fet
In your Heroku app go to Settings and add the following build packs:
In addition, in your Python script you have to set a few Chrome options so that your script runs on Heroku without error.
import time
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
gChromeOptions = webdriver.ChromeOptions()
gChromeOptions.add_argument("window-size=1920x1480")
gChromeOptions.add_argument("disable-dev-shm-usage")
gDriver = webdriver.Chrome(
chrome_options=gChromeOptions, executable_path=ChromeDriverManager().install()
)
gDriver.get("https://www.python.org/")
time.sleep(3)
gDriver.save_screenshot("my_screenshot.png")
gDriver.close()
Here is a more detailed post that I created in case you are still having problems: https://www.jtrocinski.com/posts/Heroku-Use_Selenium_to_run_Google_Chrome_in_Python.html