Goodbye phantom js

At work we do a lot of headless integration testing of our Rails applications, and we've been using PhantomJS & Capybara.

PhantomJS was discontinued in 2017 because of the development on headless chrome

Here is what I had to do in my Rails application to switch over to headless chrome:

Added these two gems to my test section of my rails Gemfile

gem 'selenium-webdriver'
gem 'chromedriver-helper'

Removed all code mentioning Poltergeist in my rails_helper

I'm using system specs now rather then feature specs, so I added these two sections to my rails_helper. It's pretty handy to be able to run the specs in non-headless mode when developing.

config.before(:each, type: :system, js: true) do
    driven_by :selenium_chrome_headless
    driven_by :selenium

Capybara.register_driver :selenium do |app|
  options = ['disable-gpu'])
      browser: :chrome,
      options: options

And here is what I needed to do to get chromium and the driver running locally on my computer

# Update the local chromedriver
$ chromedriver-update 

# Install chromium so that chromedriver has something to drive!
$ sudo apt install chromium-browser

# And finally to test if its working
$ chromedriver 
-> Starting ChromeDriver 70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778) on port 9515
-> Only local connections are allowed.