ruby-on-railsphantomjsxvfbheadless-browserengineyard

Deploying PhantomJS or headless gem on Engine Yard


I currently have an app deployed to Engine Yard. I am not familiar with importing chef recipes to Engine Yard's repo, etc. like a PhantomJS install. It appears the instance uses Amazon Linux. Is there a best practice, or even walkthrough, that would help me deploy either Xvfb or PhantomJS to my Engine Yard instance? Also, it is being used as a Rails application server.


Solution

  • I suggest the PhantomJS gem. It automatically installs PhantomJS the first time it's used, in a private location whose location you can get from an API. It provides a recent PhantomJS, currently 2.1.1. It works for me on both MacOS and Linux.

    I haven't used that gem on Engine Yard, but I don't think there should be any Engine Yard-specific issues.

    I use Cucumber, Capybara and poltergeist, so I have this in features/support/poltergeist.rb:

    require 'capybara/poltergeist'
    Capybara.javascript_driver = :poltergeist
    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, phantomjs: Phantomjs.path)
    end
    

    Using Selenium-Webdriver directly, I'd expect what rantingsonrails suggested would work:

    Selenium::WebDriver::PhantomJS.path = Phantomjs.path