How to run browser automation tests without installing Chrome or Firefox

I’m working on a Ruby on Rails project where we need to run automated feature tests using RSpec. Our team wants to use headless browser testing but we’re running into problems.

Some developers on our team don’t have Chrome installed on their machines and don’t want to install it. We also have a CI/CD pipeline where installing browsers on the server is not ideal.

I’m wondering if there’s a way to run headless browser tests without requiring the actual browser to be installed on the system. I’ve seen some conflicting information online about this.

Some articles suggest that headless mode means you don’t need the browser installed, but the official documentation for both Chrome and Firefox drivers says the browser must be present on the system.

Has anyone found a solution for this? Maybe there’s a containerized approach or a different testing tool that doesn’t have this dependency?

Honestly, try Puppeteer instead of Selenium. It comes with Chromium built-in, so you don’t need to install browsers separately. We switched our Rails app to the puppeteer-ruby gem and now tests run everywhere without any setup pain. Only downside is you’re locked into Chromium, but that’s fine for most testing.

Docker’s your best bet, but here’s another option worth checking out. We’ve been using GitHub Codespaces for our Rails project - browsers come pre-installed in the dev environment. No local installation headaches since everything runs in the cloud. For CI/CD, most major platforms include Chrome and Firefox by default now. GitHub Actions’ ubuntu-latest runner already has Chrome. Same deal with GitLab CI and CircleCI. Stuck with a custom CI setup? Use the official selenium Docker images as base images for your test runs. The selenium/standalone-chrome-debug image is great for debugging failed tests - you can VNC into it when things break. Just heads up: browser versions in these pre-built environments usually lag behind latest releases, so you might hit compatibility issues with newer web features.

I had a similar challenge last year when working with a project that required automated testing without the installation of browsers on local machines. Many assume that using ‘headless’ mode eliminates the need for having the browser, but this isn’t true; the Chrome or Firefox browser needs to be available for the respective drivers to function correctly. We managed to resolve this issue by utilizing Docker. By creating a Dockerfile that included the necessary browsers, we could execute the tests within containers. This way, team members only had to install Docker without any additional browser installations. Additionally, for CI/CD, platforms like GitHub Actions and GitLab CI provide pre-built images that contain the required browsers. Switching to an image like selenium/standalone-chrome streamlined our processes significantly. Alternatively, exploring cloud testing solutions such as BrowserStack or Sauce Labs can also work, although they may introduce extra costs and dependencies.