I keep on getting this error:
Failure/Error: page.evaluate_script('jQuery.active') == 0
Selenium::WebDriver::Error::JavascriptError:
ReferenceError: jQuery is not defined
whenever I use the script:
wait_until do
page.evaluate_script('jQuery.active') == 0
end
I've put in a debugger and checked for the jQuery library. It was existing on the particular page.
Is there something I need to configure for this to work?
EDIT:
Versions of Capybara and RSpec are:
rspec-rails-2.11.0 rspec-2.11.0 capybara-1.1.2
I ran into the same issue. I solved it by dropping a binding.pry in the test and stopping the selenium browser. Upon inspection, I noticed that the js console had thrown errors: Selenium could not find a .js file.
The root of the problem was an outdated rails test application preloaded with spring. I had installed a gem (moment-timezone-rails) but was still continuing to run my tests with 'spring rspec,' which didn't have the proper directory to find the js file.
restarting spring fixed the problem.
The error implies your example does have js:true, but it would be good to post a complete example here.
I found that switching from the default selenium driver to webkit solved a few different issues for me, and also examples run much faster.
Not an answer, per se, but it's worth trying to see if it solves your particular issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With