Several variations of this question have been asked, and I’ve definitely learned from reading up on the topic, but most of the answers didn’t seem to be directly applicable to this situation, or involved solutions using Rspec or Cucumber.
I’m currently working on a test suite using Minitest and Capybara. I don’t want to have to bring in too many other gems if possible, but I’m open to it if they’re lightweight, because tests are already taking a while to run.
Rspec has :js => true and Cucumber has @javascript, but minitest doesn’t seem to have anything like this. The natural solution, then, would be to switch drivers and do: Capybara.current_driver = :selenium, but when I do this, it doesn’t work, and I get 2 errors (one for each of my js-enabled tests).
My question is this: Why am I getting these errors, and how can I make some basic JavaScript testing work? Here’s are the errors:
Component returned failure code: 0x804b0012 (NS_ERROR_UNKNOWN_PROTOCOL) [nsIWebNavigation.loadURI]
Exception `Selenium::WebDriver::Error::UnknownError' at:
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:65:in `request'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:576:in `execute'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:99:in `get'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/navigation.rb:14:in `to'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/selenium/driver.rb:36:in `visit'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/session.rb:157:in `visit'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/dsl.rb:161:in `visit'
test/integration/resource_access_test.rb:22:in `block (2 levels) in <top (required)>'
And here’s the other error:
undefined method `[]' for nil:NilClass
Exception `NoMethodError' at:
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/rack-test-0.6.1/lib/rack/test.rb:171:in `env_for'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/rack-test-0.6.1/lib/rack/test.rb:56:in `get'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/rack_test/browser.rb:62:in `process'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/rack_test/browser.rb:21:in `visit'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb:32:in `visit'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/session.rb:157:in `visit'
/Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/dsl.rb:161:in `visit'
test/integration/resource_access_test.rb:40:in `block (2 levels) in <top (required)>'
Does anyone know what could be going on here, as well as how I can fix this issue?
Try the following syntax to switch Capybara drivers: