title: How to have jQuery work with PhantomJS, Poltergeist and Capybara
body: <p>I have a series of automated tests in Ruby that use Capybara, Poltergeist and PhantomJS to interact with webpages.  However, the problem is some of the pages are not working properly because jQuery does not appear to be getting loaded.  For instance, on one webpage there is code like:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  &lt;!--
    jQuery(window).load(function() {
      //Do Javascript-y things
    });
  //--&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>But this does not seem to work/run.  From what I've read it appears that PhantomJS does not work naturally with jQuery (or at the very least it does not automatically load jQuery).  How can I fix this.  Keep in mind I can't change the webpage's actual code.</p>
  
  <p>Summary: How can I add/inject/load jQuery when using PhantomJS, Poltergeist and Capybara?</p>
  
  <p>EDIT: Here is how I'm using phantomjs.  Notice how I never actually use phantomjs directly.  The phantomjs executable is indirectly used by Poltergeist:</p>
  
  <pre><code>Capybara.register_driver :poltergeist do |app|
      driver = Capybara::Poltergeist::Driver.new(app,
                                        :debug =&gt; debug,
                                        :window_size =&gt; [1616, 1000],
                                        :js_errors =&gt; true,
                        :cookies =&gt; true,
      :phantomjs_options =&gt; ['--ignore-ssl-errors=true', 
                 '--web-security=false', 
                 '--local-to-remote-url-access=true', 
                 '--proxy-type=none' ],:timeout =&gt; 180
         )       
  </code></pre>