8

When I set one of my rspec tests to :js => true I get the following error. I'm using the following versions:

Rails — 3.2.2
Rspec — 2.9.0
Capybara — 1.1.2

According to the docs, Capybara should run any specs using :js => true through Selenium. I tried adding Selenium to my Gemfile, in case Capybara wasn't able to find it but that didn't work.

1) UserSignups GET /signup supports js
 Failure/Error: visit signup_path
 LoadError:
   no such file to load -- {
     "frozen": {
       "app.update.auto": false,
       "app.update.enabled": false,
       "browser.download.manager.showWhenStarting": false,
       "browser.EULA.override": true,
       "browser.EULA.3.accepted": true,
       "browser.link.open_external": 2,
       "browser.link.open_newwindow": 2,
       "browser.offline": false,
       "browser.safebrowsing.enabled": false,
       "browser.safebrowsing.malware.enabled": false,
       "browser.search.update": false,
       "browser.sessionstore.resume_from_crash": false,
       "browser.shell.checkDefaultBrowser": false,
       "browser.tabs.warnOnClose": false,
       "browser.tabs.warnOnOpen": false,
       "devtools.errorconsole.enabled": true,
       "dom.disable_open_during_load": false,
       "extensions.autoDisableScopes": 10,
       "extensions.logging.enabled": true,
       "extensions.update.enabled": false,
       "extensions.update.notifyUser": false,
       "network.manage-offline-status": false,
       "network.http.phishy-userpass-length": 255,
       "offline-apps.allow_by_default": true,
       "prompts.tab_modal.enabled": false,
       "security.fileuri.origin_policy": 3,
       "security.fileuri.strict_origin_policy": false,
       "security.warn_entering_secure": false,
       "security.warn_entering_secure.show_once": false,
       "security.warn_entering_weak": false,
       "security.warn_entering_weak.show_once": false,
       "security.warn_leaving_secure": false,
       "security.warn_leaving_secure.show_once": false,
       "security.warn_submit_insecure": false,
       "security.warn_viewing_mixed": false,
       "security.warn_viewing_mixed.show_once": false,
       "signon.rememberSignons": false,
       "toolkit.networkmanager.disable": true,
       "toolkit.telemetry.prompted": 2,
       "toolkit.telemetry.enabled": false,
       "toolkit.telemetry.rejected": true
     },
     "mutable": {
       "browser.dom.window.dump.enabled": true,
       "browser.startup.page": 0,
       "browser.startup.homepage": "about:blank",
       "dom.max_script_run_time": 30,
       "dom.report_all_js_exceptions": true,
       "javascript.options.showInConsole": true,
       "network.http.max-connections-per-server": 10,
       "webdriver_accept_untrusted_certs": true,
       "webdriver_assume_untrusted_issuer": true
     }
   }
3
  • I have this exact same issue. Any information? Commented Apr 26, 2012 at 14:22
  • 1
    Tracking it down through the stack, it seems that the MultiJson.load(obj) call in the selenium-webdriver-2.21.2/lib/selenium/webdriver.rb file is throwing the LoadError. Which versions of the selenium-webdriver, capybara and multi-json gems are you using? Commented Apr 26, 2012 at 14:44
  • I have selenium-webdriver 2.21.2 and multi_json 1.1.0. Commented Apr 26, 2012 at 15:46

3 Answers 3

10

i had the same issue now for 3 days! it was driving me nuts!

short answer: downgrade selenium-webdriver to 2.21.1

long explanation: after some digging into the source code i can verify the issue is selenium-webdriver 2.21.2 inside a Rails app (i test on rails 3.0.x personally).

the offending line of code can be found here http://code.google.com/p/selenium/source/browse/trunk/rb/lib/selenium/webdriver.rb?r=16651#78

the root cause is in a Rails app the class ActiveSupport::Dependencies::Loadable defines a class level method called load on Object, therefore the check MultiJson.respond_to?(:load) always returns true but its the wrong load method.

Sign up to request clarification or add additional context in comments.

Comments

7

This can also be worked around by upgrading multi_json to the latest version.

Comments

1

I was having the same problem, the solution for me was change the drive that I was using. So for example:

scenario "answering the quiz for my recipient", :js => true, :driver => :rack_test do
    click_button "Continue"
end

This way I'm using the rack_test instead of the selenium-webdrive ( the default of Capybara ).

Hope this help you!

1 Comment

But then the spec won't run JS. It needs a browser to handle JS in your specs, so changing the driver to :rack_test prevents it from launching Firefox. I may be wrong!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.