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:
<script type="text/javascript">
<!--
jQuery(window).load(function() {
//Do Javascript-y things
});
//-->
</script>
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.
Summary: How can I add/inject/load jQuery when using PhantomJS, Poltergeist and Capybara?
EDIT: Here is how I'm using phantomjs. Notice how I never actually use phantomjs directly. The phantomjs executable is indirectly used by Poltergeist:
Capybara.register_driver :poltergeist do |app|
driver = Capybara::Poltergeist::Driver.new(app,
:debug => debug,
:window_size => [1616, 1000],
:js_errors => true,
:cookies => true,
:phantomjs_options => ['--ignore-ssl-errors=true',
'--web-security=false',
'--local-to-remote-url-access=true',
'--proxy-type=none' ],:timeout => 180
)
head
tag. – Andrei Botalov