Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara + Selenium + RSpec — LoadError when setting JS to true

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
     }
   }
like image 445
Phil Jeffs Avatar asked Apr 26 '12 13:04

Phil Jeffs


2 Answers

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.

like image 113
george Avatar answered Oct 04 '22 23:10

george


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

like image 35
jarib Avatar answered Oct 04 '22 22:10

jarib