title: PhantomJS not running javascript when setup through capybara with poltergeist
body: <p>The way I'm setting up the capybara driver seems to be causing phantomjs to not execute javascript.  To confirm that this can work outside of capybara / poltergeist, I used raw watir-webdriver with the same phantomjs installation and it did run javascript.</p>
  
  <p>So here is my code that creates the capybara driver using poltergeist:</p>
  
  <pre><code>require 'capybara'
  require 'capybara/poltergeist'
  
  include Capybara::DSL
  
  Capybara.register_driver :poltergeist do |app|
    options = {
      :js_errors =&gt; true,
      :timeout =&gt; 120,
      :debug =&gt; false,
      :phantomjs_options =&gt; ['--load-images=no', '--disk-cache=false'],
      :inspector =&gt; true,
    }
    Capybara::Poltergeist::Driver.new(app, options)
  end
  
  Capybara.default_driver = :poltergeist
  Capybara.javascript_driver = :poltergeist
  Capybara.app_host = 'https://google.com'
  
  visit('/')
  fill_in('q', with: 'green cheese')
  sleep 2
  
  p all('span').map{|s| s.text}
  </code></pre>
  
  <p>When I run that I get out like:</p>
  
  <pre><code>["", "", "+You", "", "Search", "", "Images", "", "Maps", "", "Play", "", "YouTube", "", "News", "", "Gmail", "", "More", "More", "", "", "", "Sign in", "Sign in", "", "", "", "", "× A faster way to browse the web Install Google Chrome", "", "", "", "", "Advertising ProgramsBusiness Solutions+GoogleAbout Google © 2013 - Privacy &amp; Terms"]
  </code></pre>
  
  <p>Which makes it clear that the search suggestions are not showing up, which means javascript is not running.  I've confirmed this using screenshots.</p>
  
  <p>Now, when I run the following code that uses only water-webdriver, it works:</p>
  
  <pre><code>require 'watir-webdriver'
  
  b = Watir::Browser.new :phantomjs
  
  b.goto 'https://google.com'
  b.text_field(:name, 'q').set "green cheese"
  sleep 2
  p b.spans.map{|s| s.text }
  b.close
  </code></pre>
  
  <p>and that gives the following output:</p>
  
  <pre><code>["", "", "+You", "", "Search", "", "Images", "", "Maps", "", "Play", "", "YouTube", "", "News", "", "Gmail", "", "More", "More", "", "", "", "Sign in", "Sign in", "", "", "", "", "×\nA faster way to browse the web\nInstall Google Chrome", "", "", "", "", "Advertising ProgramsBusiness Solutions+GoogleAbout Google\n© 2013 - Privacy &amp; Terms", "green cheese", "green cheese strain", "green cheese weed", "green cheese enchiladas", "green cheesecake", "green cheese moon", "green cheese enchiladas recipe", "green cheese strain review", "green cheese media group", "green cheese penny", "", "", "", ""]
  </code></pre>
  
  <p>All that green cheese in there makes it clear that search suggestions are showing up, which means javascript must be running.  Again, I have confirmed this using screenshots.</p>
  
  <p>Can anyone help me understand how to configure Capybara/poltergeist so it works?</p>
  
  <p>One final note: This has nothing to do with Rails.  this is a standalone test suite, and you can find the full code for it here:  <a href="https://github.com/rschultheis/rspec_capybara_starter" rel="nofollow">https://github.com/rschultheis/rspec_capybara_starter</a></p>