Search code examples
ruby-on-railsphantomjscapybarapoltergeist

What caused Poltergeist screenshot to stop working when using Capybara 2.15.4?


Previously, I had Capybara 2.5, and Poltergeist page.save_screenshot worked just fine. But, recently, I've just upgraded my Capybara to 2.15.4, and that caused Poltergeist page.save_screenshot not to work anymore. The file is not created.

Here is my feature spec:

feature 'create', js: true do
  before do
    visit root_path
  end

  scenario 'valid' do
    page.save_screenshot('test.png')
  end
end

spec_helper.rb:

require 'capybara/poltergeist'

Capybara.register_driver :poltergeist do |app|
  options = {
    js_errors: false,
    phantomjs_options: ['--load-images=false', '--ignore-ssl-errors=yes', '--ssl-protocol=any'],
    timeout: 60,
    debug: true
  }
  Capybara::Poltergeist::Driver.new(app, options)
end
Capybara.javascript_driver = :poltergeist

My current environment:

Ruby 2.3.3
Capybara 2.15.4
Poltergeist 1.9.0
PhantomJS 2.1.1

Solution

  • You've update Capybara, but not updated Poltergeist. There was an update in Capybara 2.7 where Capybara.save_and_open_page_path was deprecated in favor of Capybara.save_path with slightly different behavior around relative paths. Update Poltergeist as well and your issue will probably go away.