Cucumber (rails 2) not loading jQuery

I have a cucumber script with a tag @javascriptand I am testing it with some really basic js built-in calls. I run this with

Capybara.javascript_driver =: webkit

If I do this on the page, after this element has id = "ajax_test_results", don't worry about ajax, though, for now)

document.getElementById('ajax_test_results').innerHTML = 'Replaced with basic js, ie not jquery, without waiting for pageLoad';  

then it works: if I crossed out the page in my test, I see that js started and updated the content. However, if I try to do the same with jquery

jQuery("#ajax_test_results").html("updated with basic jquery dom manipulation, without waiting for document.ready");  

then it will not work. I think jquery is not loading, but I do not know how to debug it.

Any ideas? I saw this post that looked reliable https://stackoverflow.com/questions/8428405/cucumber-tests-jquery-does-not-loaded-in-webdriver , but config.assets.debug = truecauses an error for me - I think it’s only rails 3 Are there rails of 2 equivalents? or some other solution?

Grateful for any advice - max

+5
source share
1 answer

For debugging you can use console.log ('message') or alerts. It displays your messages on the terminal screen. Also you can use:

Gemfile:
  gem 'debugger'

When /your step/ do
  require 'ruby-debug'
  debugger
end

then you can debug using the methods page.evaluate_script or page.execute_script. This is pretty easy to do.

According to jquery problem, can you try using $ instead of jQuery?

Alex

0
source

All Articles