Search code examples
ruby-on-railsrubycapybaraintegration-testingpoltergeist

Undefined method for save_screenshot for Capybara and Poltergeist


I'm using capybara (1.1.4), poltergeist (1.0.2) and rails (3.2.13). I'm trying to take a screenshot to debug some errors I'm getting. However, both the capybara and poltergeist save screenshot methods aren't working. When I do poltergeist (and all my tests have js: true), I get this:

Failure/Error: save_screenshot('test.png')
     NoMethodError:
       undefined method `save_screenshot' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fb5fcce3178>

When I do the Capybara way I get this:

Failure/Error: page.save_screenshot('screenshot.png')
     NoMethodError:
       undefined method `save_screenshot' for #<Capybara::Session>

I'm completely stumped on why this isn't working and googling has been completely unhelpful. If you need more info, just ask and I'll respond ASAP. I'd really appreciate the help!


Solution

  • I noticed you stated you were on poltergeist 1.0.2 yet the syntax you are using is from a later version. Try upgrading to version 1.3.0.