Before there was headless Chrome and Firefox, there was the PhantomJS headless browser.
With the rise of headless Chrome and Firefox and lack of active contributors, PhantomJS development has been suspended since March 2018.
It is highly recommended to use headless Chrome and Firefox, particularly the SeleniumHQ-maintained Docker images instead of the legacy PhantomJS browser.
The PhantomJS browser requires the Poltergeist driver.
This gist documents using PhantomJS/Poltergeist in Capybara (RSpec) for historical reference.
To avoid having to download and manage the PhantomJS browser manually, use the phantomjs-helper gem.
The following is a minimal Capybara-RSpec Gemfile
for using PhantomJS...
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'capybara'
gem 'phantomjs-helper'
gem 'poltergeist'
gem 'rspec'
The following is a minimal Capybara-RSpec spec-helper.rb
for using PhantomJS...
# frozen_string_literal: true
require 'capybara'
require 'capybara/poltergeist'
require 'capybara/rspec'
Capybara.default_driver = :poltergeist