Cucumber via Envjs says "a.ownerDocument is null"
By: Johnathon Wright on: March 10, 2011
I recently received the following errors when running capybara with envjs. Strangely, there was a kind of double stack trace. Here are the exeptions:
=== WARNIING: [Thu Mar 10 2011 09:54:41 GMT-0600 (CST)] {ENVJS} Exception while dispatching events: a.ownerDocument is null
a.ownerDocument is null (Johnson::Error)
=== WARNIING: [Thu Mar 10 2011 09:54:41 GMT-0600 (CST)] {ENVJS} Exception while dispatching events: a.ownerDocument is null oopse a.ownerDocument is null undefined
inline:129 [JavaScript]
===diff
--- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,4 +1,4 @@ -ENV["RAILSENV"] ||= "cucumber" +ENV["RAILSENV"] ||= "test"
require File.expandpath(File.dirname(FILE_) + '/../../config/environment')
@@ -20,7 +20,6 @@ require 'capybara/session' Capybara.default_selector = :css
require 'capybara/envjs' -Capybara.javascript_driver = :envjs
Before do
User.test = Factory.create(:user)
and for reference:
=== diff config/environments/test.rb config/environments/cucumber.rb
< config.gem 'factory_girl' < config.gem 'rspec', :lib => false < config.gem 'rspec-rails', :lib => false
< config.gem 'capybara-envjs', :lib => 'capybara/envjs'
config.gem 'capybara-envjs', :lib => 'capybara/envjs' config.gem 'factory_girl' config.gem 'cucumber', :lib => false config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
config.gem 'databasecleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/databasecleaner'))
my complete features/support/env.rb file:
ENV["RAILS_ENV"] ||= "test"
require File.expandpath(File.dirname(FILE_) + '/../../config/environment')
puts "========================================" puts "RAILSENV is #{RAILSENV} " puts "========================================"
require File.expandpath(File.dirname(FILE_) + '/../../test/helpers/user.rb')
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support require 'cucumber/rails/world' require 'cucumber/rails/active_record' require 'cucumber/web/tableish'
require 'capybara/rails' require 'capybara/cucumber' require 'capybara/session'
Capybara.default_selector = :css
require 'capybara/envjs'
Before do User.test = Factory.create(:user) Given 'I am logged in'
System.destroy_all System.load end
ActionController::Base.allowrescue = false Cucumber::Rails::World.usetransactional_fixtures = true
if defined?(ActiveRecord::Base) begin require 'databasecleaner' DatabaseCleaner.strategy = :truncation rescue LoadError => ignoreifdatabasecleanernotpresent end