sobrinho/capybara-celerity — Issue #5: undefined method `xpath' for nil:NilClass when doing a select
Author: duelinmarkers
Created: 2011-11-04 15:02:59+00:00
State: open

When we try to use the capybara select method to select an option in a dropdown, it blows up. We can use the Celerity API the select the option without a problem.

Environment:
jruby-1.6.5
capybara (1.0.0)
capybara-celerity (0.0.1)
nokogiri (1.5.0 java)

From some digging around it looks like Nokogiri doesn't understand an xpath returned by celerity.

Here's a failing spec using a publicly available page:

```ruby
require 'capybara'
require 'capybara/dsl'
require 'capybara/celerity'

Capybara.configure do |config|
config.run_server = false

# disabling javascript exceptions until htmlunit is more stable
browser_options = {:browser => :ff3,
:viewer => false,
:log_level => :severe,
:javascript_exceptions => false,
:status_code_exceptions => false,
:css => true,
:resynchronize => true,
:secure_ssl => false,
:refresh_handler => :waiting}

config.register_driver :celerity do |app|
# config::Driver::Celerity.new(app, browser_options)
config::Driver::Celerity.new(app)
end

config.default_driver = :celerity
config.default_wait_time = 30
end

describe "Orbitz hotel page" do
include Capybara::DSL

it "should search for a hotel" do
visit "http://www.orbitz.com"
choose "htlChoice"
fill_in "htlTarget", :with => "Orlando"
page.should have_select("htlRooms")
page.should have_select("htlRooms", :options => ['1', '2'])
select "1", :from => "htlRooms"
end
end
```

```
Failures:

1) Orbitz hotel page should search for a hotel
Failure/Error: select "1", :from => "htlRooms"
NoMethodError:
undefined method `xpath' for nil:NilClass
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-celerity-0.0.1/lib/capybara/driver/celerity.rb:81:in `find'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/node/finders.rb:160:in `find_in_base'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/node/finders.rb:147:in `first'
# org/jruby/RubyArray.java:1612:in `each'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/node/finders.rb:146:in `first'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/node/finders.rb:28:in `find'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/node/finders.rb:168:in `wait_conditionally_until'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/session.rb:244:in `wait_until'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/util/timeout.rb:13:in `timeout'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/session.rb:244:in `wait_until'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/node/finders.rb:168:in `wait_conditionally_until'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/node/finders.rb:28:in `find'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/node/actions.rb:115:in `select'
# org/jruby/RubyKernel.java:2101:in `send'
# (eval):2:in `select'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/capybara-1.0.0/lib/capybara/dsl.rb:143:in `select'
# ./test_spec.rb:37:in `(root)'
# org/jruby/RubyKernel.java:2062:in `instance_eval'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:48:in `run'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:107:in `with_around_hooks'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:45:in `run'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:294:in `run_examples'
# org/jruby/RubyArray.java:2318:in `collect'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in `run_examples'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:262:in `run'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `run'
# org/jruby/RubyArray.java:2318:in `collect'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `run'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/reporter.rb:12:in `report'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:21:in `run'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
# /Users/hume/Projects/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'

Finished in 9.91 seconds
1 example, 1 failure
```