Search code examples
phantomjscapybarapoltergeist

Suppressing PhantomJS error output


I'm running Cucumber tests in Capybara with Poltergeist and I'm seeing the PhantomJS error for Function.prototype.bind in some of my tests. (The shim isn't working for some reason.) I'd like to suppress the output from phantom.

I've tried

Capybara.register_driver :poltergeist do |app|
  options = {
    :debug => false,
    :js_errors => false,
    :phantomjs_options => ['--debug=no'],
  }
  Capybara::Poltergeist::Driver.new(app, options)
end

but I'm still seeing the stacktrace. Is there a different way to tell phantom that I don't want to see any exceptions in STDOUT?


Solution

  • I ended up solving this by setting :phantomjs_logger to Logger.new("/dev/null")

    Well apparently dumping output to null makes poltergeist timeout a lot.

    Using StringIO.new does work, however.