I’m trying to figure out how to run automated browser tests on Heroku without displaying the actual browser window. My team built a testing script that uses Selenium to control Firefox, and it works perfectly on our local machines where we can see the browser opening and running the tests.
The problem is that Heroku doesn’t support graphical interfaces, so we need to run our browser automation in the background. I’m wondering if there are specific configuration settings or browser parameters we can add to make our existing Selenium code work in a non-visual mode.
We want to avoid rewriting our entire test suite if possible. What options should we configure to make this transition smooth? Any advice on the best approach for headless browser automation on cloud platforms would be really helpful.
Had the same issue deploying Selenium tests to Heroku last year. Super easy fix: just add the headless option to your FirefoxOptions before creating the driver instance. Don’t forget to include the Firefox buildpack in your Heroku app too. Headless mode does everything a regular browser does minus the visual stuff - actually runs faster. I didn’t change any test logic, just tweaked the driver setup. Heads up though - some interactions can behave differently in headless mode, so test your critical flows after deployment to make sure everything works.
I switched from local Selenium to Heroku six months ago and hit the same issues. You’ll need headless mode plus specific Firefox arguments for Heroku. Add no-sandbox and disable-dev-shm-usage flags to avoid memory problems. I’d also throw in disable-gpu and window-size parameters - keeps things consistent across tests. The Firefox buildpack installs the browser automatically, but double-check your requirements.txt has a Selenium version that plays nice with the buildpack’s Firefox. Learned this one the hard way: Heroku’s filesystem is ephemeral, so screenshots and downloads disappear when dynos restart. You’ll need to rework any test assertions that depend on saved files.
firefox is a pain on heroku. switch to chrome - it’s way more stable headless and the google-chrome buildpack just works better. change webdriver.Firefox() to webdriver.Chrome(), add --headless --no-sandbox flags, and ur done. saves u tons of headaches vs fighting firefox’s quirks in production.