Rails 3.1 Capybara jQuery undefined

I keep getting this error:

Failure/Error: page.evaluate_script('jQuery.active') == 0 Selenium::WebDriver::Error::JavascriptError: ReferenceError: jQuery is not defined 

whenever i use script:

 wait_until do page.evaluate_script('jQuery.active') == 0 end 

I put in the debugger and checked the jQuery library. It was created on a specific page.

Is there something I need to configure for this?

EDIT:

Versions of Capybara and RSpec:

RSpec rails-2.11.0 RSpec-2.11.0 capybara-1.1.2

+6
source share
3 answers

The error implies that your example has js: true, but it would be nice to post the full example here.

I found that switching from the standard selenium driver to webkit solved a few different problems for me, and the examples run much faster.

Not the answer in itself, but it's worth trying to figure out if it solves your specific problem.

0
source

I ran into the same problem. I solved this by dropping bind.pry in the test and stopping the selenium browser. When checking, I noticed that the js console generated errors: Selenium could not find the .js file.

The root of the problem was an outdated rails test application preloaded with spring. I installed the gem (points-in-rails), but still continued to run my tests using spring rspec, which did not have the proper directory to search for the js file.

restarting spring fixed the problem.

0
source

I had the same problem with FF 41.0.2 and capybara-webkit 3.4.0. After updating FF to 53.0.3, the problem went away

0
source

Source: https://habr.com/ru/post/927906/


All Articles